Summer Special - Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: top65certs

Java SE 1z0-809 Exam Questions and Answers PDF

Page: 14 / 16
Total 208 questions

Java SE 8 Programmer II Questions and Answers

Question 53

Given:

public class Customer {

private String fName;

private String lName;

private static int count;

public customer (String first, String last) {fName = first, lName = last;

++count;}

static { count = 0; }

public static int getCount() {return count; }

}

public class App {

public static void main (String [] args) {

Customer c1 = new Customer(“Larry”, “Smith”);

Customer c2 = new Customer(“Pedro”, “Gonzales”);

Customer c3 = new Customer(“Penny”, “Jones”);

Customer c4 = new Customer(“Lars”, “Svenson”);

c4 = null;

c3 = c2;

System.out.println (Customer.getCount());

}

}

What is the result?

Options:

A.

0

B.

2

C.

3

D.

4

E.

5

Question 54

Given:

public class Counter {

public static void main (String[ ] args) {

int a = 10;

int b = -1;

assert (b >=1) : “Invalid Denominator”;

int с = a / b;

System.out.println (c);

}

}

What is the result of running the code with the –da option?

Options:

A.

-10

B.

0

C.

An AssertionError is thrown.

D.

A compilation error occurs.

Question 55

Given the code fragment:

List nums = Arrays.asList (10, 20, 8):

System.out.println (

//line n1

);

Which code fragment must be inserted at line n1 to enable the code to print the maximum number in the nums list?

Options:

A.

nums.stream().max(Comparator.comparing(a -> a)).get()

B.

nums.stream().max(Integer : : max).get()

C.

nums.stream().max()

D.

nums.stream().map(a -> a).max()

Question 56

Given:

What is the result?

Options:

A.

Bar HelloFoo Hello

B.

Bar HelloBaz Hello

C.

Baz Hello

D.

A compilation error occurs in the Daze class.

Page: 14 / 16
Total 208 questions