The LocalTime is an interface, so we can't use new keyword with them. So options A and C are incorrect. To get current time we can call now method on LocalTime interface. So option C is correct. Option D is incorrect as there is no method called today as in LocalTime interface

https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html

Q152. Given the code from the Greeting.Java file:

Which set of commands prints Hello Duke in the console?

A. Option A

B. Option B

C. Option C

D. Option D

Answer: C

Q153. Given the code fragment:

What is the result?

A. Jesse 25 Walter 52

B. Compilation fails only at line n1

C. Compilation fails only at line n2

D. Compilation fails at both line n1 and line n2

Answer: D

Q154. Given:

What is the result?

A. Option A

B. Option B

C. Option C

D. Option D

Answer: B

Q155. Given:

What is the output?

A. [21, 13, 11]

B. [30]

C. []

D. Compilation fails due to error at line 7

E. Compilation tails due to error at line 10

Answer: D

Explanation:

Option D is the correct answer.

Code fails to compile as we can't use primitive for collections type, so in this code trying to

use int at line 7, causes a compile error. We should have use wrapper. Integer there. So

option D is correct.

https://docs.oracle.eom/javase/8/docs/api/java/util/ArrayList.html

Improve 1z0-808 test question:

Q156. Given:

public class TestLoop1 {

public static void main(String[] args) {

int a = 0, z=10;

while (a < z) {

a++;

--z;

} System.out.print(a + " : " + z); } }

What is the result?

A. 5 : 5

B. 6 : 4

C. 6 : 5

D. 5 : 4

Answer: A

Q157. Given:

What is the result?

A. true:true

B. true:false

C. false:true

D. false:false

Answer: C

Q158. Given:

public class ComputeSum {

public int x;

public int y;

public int sum;

public ComputeSum (int nx, int ny) {

x = nx; y =ny;

updateSum();

}

public void setX(int nx) { x = nx; updateSum();}

public void setY(int ny) { x = ny; updateSum();}

void updateSum() { sum = x + y;}

}

This class needs to protect an invariant on the sum field.

Which three members must have the private access modifier to ensure that this invariant is maintained?

A. The x field

B. The y field

C. The sum field

D. The ComputerSum ( ) constructor

E. The setX ( ) method

F. The setY ( ) method

Answer: C,E,F

Explanation: The sum field and the two methods (setX and SetY) that updates the sum field.