1z0-808 | Refined Java 1z0-808 examcollection


Q71. Given: 

Which of the following is equivalent to the above code fragment? 

A. System.out.printLn(x>10?">,': "<":,'="); 

B. System.out.println(x>10? ">"?"<":"="); 

C. System.out.println(x>10?">":x<10?"<":"="); 

D. System.out.printLn(x>10?">"?,'<"?"="); 

E. None of the above 

Answer:

Explanation: 

Option A is incorrect as we can't use abstract with non abstract method, (here method has method body.) Option C is incorrect as when overriding method we can't use more restrictive access modifier, so trying to use private to override default access Level method causes a compile time error. Option D is incorrect as default methods (not methods with default access level) are allowed only in interfaces. Option E is incorrect as method all ready has void as return type, so we can't add int there. Option B is correct as we can use final there, since the method is non abstract 

https://docs.oracle.com/javase/tutorial/java/landl/polymorphism.html 

Q72. Given the code fragment: 

// insert code here 

arr[0] = new int[3]; 

arr[0][0] = 1; 

arr[0][1] = 2; 

arr[0][2] = 3; 

arr[1] = new int[4]; 

arr[1][0] = 10; 

arr[1][1] = 20; 

arr[1][2] = 30; 

arr[1][3] = 40; 

Which two statements, when inserted independently at line // insert code here, enable the code to compile? 

A. int [] [] arr = null; 

B. int [] [] arr = new int [2]; 

C. int [] [] arr = new int [2] [ ]; 

D. int [] [] arr = new int [] [4]; 

E. int [] [] arr = new int [2] [0]; 

F. int [] [] arr = new int [0] [4]; 

Answer: C,E 

Q73. Given: 

What is the result? 

A. int main 1 

B. Object main 1 

C. String main 1 

D. Compilation fails 

E. An exception is thrown at runtime 

Answer:

Q74. Which statement is/are true? 

I. Default constructor only contains "super();" call. 

II. We can't use any access modifier with a constructor. 

III. A constructor should not have a return type. 

A. Only I. 

B. Only II. 

C. Only I and II. 

D. Only I and III. 

E. AIL 

Answer:

Explanation: 

Statement I is correct as the default constructor only contains super0 call 

Statement II is incorrect as we can use any access modifier with a constructor. 

Statement III is correct as constructor can't have return type, even void. 

So option D is correct. 

httpsy/docs.oracle.com/javase/tutorial/iava/javaOO/construaors.html 

Q75. Given: 

What is the result? 

A. true true 

B. true false 

C. false true 

D. false false 

E. Compilation fails 

Answer:

Q76. Which two items can legally be contained within a java class declaration? 

A. An import statement 

B. A field declaration 

C. A package declaration 

D. A method declaration 

Answer: B,D 

Reference: 

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html 

Q77. Given: 

What is the result? 

A. 0 Done 

B. First Exception Done 

C. Second Exception 

D. Done Third Exception 

E. Third Exception 

Answer:

Q78. View the exhibit: 

public class Student { 

public String name = ""; 

public int age = 0; 

public String major = "Undeclared"; 

public boolean fulltime = true; 

public void display() { 

System.out.println("Name: " + name + " Major: " + major); } 

public boolean isFullTime() { 

return fulltime; 

Which line of code initializes a student instance? 

A. Student student1; 

B. Student student1 = Student.new(); 

C. Student student1 = new Student(); 

D. Student student1 = Student(); 

Answer:

Q79. Given the code fragment: 

What is the result if the integer aVar is 9? 

A. 10 Hello world! 

B. 10 Hello universe! 

C. 9 Hello world! 

D. Compilation fails. 

Answer:

Q80. Given: 

public class MyClass { 

public static void main(String[] args) { 

while (int ii = 0; ii < 2) { 

ii++; 

System.out.println("ii = " + ii); 

What is the result? 

A. ii = 1 ii = 2 

B. Compilation fails 

C. The program prints nothing 

D. The program goes into an infinite loop with no output 

E. The program goes to an infinite loop outputting: ii = 1 ii = 1 

Answer:

Explanation: The while statement is incorrect. It has the syntax of a for statement. 

The while statement continually executes a block of statements while a particular condition is true. Its syntax can be expressed as: 

while (expression) { statement(s) } The while statement evaluates expression, which must return a boolean value. If the expression evaluates to true, the while statement executes the statement(s) in the while block. The while statement continues testing the expression and executing its block until the expression evaluates to false. 

Reference: The while and do-while Statements