1z0-808 | Most recent Oracle 1z0-808 dumps


Q121. Given the following code: 

What is the output? 

A. 4 

B. 3 

C. 4 

D. 5 

E. 4 

F. 4 

21 

Answer:

Q122. Given the code fragment: 

int b = 3; 

if ( !(b > 3)) { 

System.out.println("square "); 

}{ 

System.out.println("circle "); 

System.out.println("..."); 

What is the result? 

A. square... 

B. circle... 

C. squarecircle... 

D. Compilation fails. 

Answer:

Q123. Given: 

public class ColorTest { 

public static void main(String[] args) { 

String[] colors = {"red", "blue","green","yellow","maroon","cyan"}; 

int count = 0; 

for (String c : colors) { 

if (count >= 4) { 

break; 

else { 

continue; 

if (c.length() >= 4) { 

colors[count] = c.substring(0,3); 

count++; 

System.out.println(colors[count]); 

What is the result? 

A. Yellow 

B. Maroon 

C. Compilation fails 

D. A StringIndexOutOfBoundsException is thrown at runtime. 

Answer:

Explanation: The line, if (c.length() >= 4) {, is never reached. This causes a compilation error. 

Note: The continue statement skips the current iteration of a for, while , or do-while loop. An unlabeled.break.statement terminates the innermost.switch,.for,.while, or.do-while.statement, but a labeled.break.terminates an outer statement. 

Q124. Given: 

And the commands: 

Javac Test.java 

Java Test 12345 

What is the result? 

A. Number us : 12345 

B. A NullPointerException is thrown at runtime 

C. A NumberFormatException is thrown at runtime 

D. AnArrayIndexOutOfBoundException is thrown at runtime. 

Answer:

Q125. Class StaticField { 

static int i = 7; 

public static void main(String[] args) { 

StaticFied obj = new StaticField(); 

obj.i++; 

StaticField.i++; 

obj.i++; 

System.out.println(StaticField.i + " "+ obj.i); 

What is the result? 

A. 10 10 

B. 8 9 

C. 9 8 

D. 7 10 

Answer:

Q126. Given: 

public class Painting { 

private String type; 

public String getType() { 

return type; 

public void setType(String type) { 

this.type = type; 

public static void main(String[] args) { 

Painting obj1 = new Painting(); 

Painting obj2 = new Painting(); 

obj1.setType(null); 

obj2.setType("Fresco"); 

System.out.print(obj1.getType() + " : " + obj2.getType()); 

What is the result? 

A. : Fresco 

B. null : Fresco 

C. Fresco : Fresco 

D. A NullPointerException is thrown at runtime 

Answer:

Q127. Which three statements are true about the structure of a Java class? 

A. A class can have only one private constructor. 

B. A method can have the same name as a field. 

C. A class can have overloaded static methods. 

D. A public class must have a main method. 

E. The methods are mandatory components of a class. 

F. The fields need not be initialized before use. 

Answer: A,B,C 

Explanation: A: Private constructors prevent a class from being explicitly instantiated by its 

callers. 

If the programmer does not provide a constructor for a class, then the system will always 

provide a default, public no-argument constructor. To disable this default constructor, 

simply add a private no-argument constructor to the class. This private constructor may be 

empty. 

B: The following works fine: 

int cake() { 

int cake=0; 

return (1); 

C: We can overload static method in Java. In terms of method overloading static method 

are just like normal methods and in order to overload static method you need to provide 

another static method with same name but different method signature. 

Incorrect: 

Not D: Only a public class in an application need to have a main method. 

Not E: 

Example: 

class A 

public string something; 

public int a; 

Q: What do you call classes without methods? Most of the time: An anti pattern. 

Why? Because it faciliates procedural programming with "Operator" classes and data 

structures. You separate data and behaviour which isn't exactly good OOP. 

Often times: A DTO (Data Transfer Object) 

Read only datastructures meant to exchange data, derived from a business/domain object. 

Sometimes: Just data structure. 

Well sometimes, you just gotta have those structures to hold data that is just plain and 

simple and has no operations on it. 

Not F: Fields need to be initialtized. If not the code will not compile. 

Example: 

Uncompilable source code - variable x might not have been initialized 

Q128. Given: 

How many MarkList instances are created in memory at runtime? 

A. 1 

B. 2 

C. 3 

D. 4 

Answer:

Q129. Given the code fragment: 

Which three lines fail to compile? 

A. Line 7 

B. Line 8 

C. Line 9 

D. Line 10 

E. Line 11 

F. Line 12 

Answer: A,D,F 

Q130. Given: 

class Cake { 

int model; 

String flavor; 

Cake() { 

model = 0; 

flavor = "Unknown"; 

public class Test { 

public static void main(String[] args) { 

Cake c = new Cake(); 

bake1(c); 

System.out.println(c.model + " " + c.flavor); 

bake2(c); 

System.out.println(c.model + " " + c.flavor); 

public static Cake bake1(Cake c) { 

c.flavor = "Strawberry"; 

c.model = 1200; 

return c; 

public static void bake2(Cake c) { 

c.flavor = "Chocolate"; 

c.model = 1230; 

return; 

What is the result? 

A. 0 unknown 0 unknown 

B. 1200 Strawberry 1200 Strawberry 

C. 1200 Strawberry 1230 Chocolate 

D. Compilation fails 

Answer:

Explanation: 1200 Strawberry 1230 Chocolate