Pass4itsure > Oracle > Oracle Database > 1Z0-809 > 1Z0-809 Online Practice Questions and Answers

1Z0-809 Online Practice Questions and Answers

Questions 4

Which two reasons should you use interfaces instead of abstract classes? (Choose two.)

A. You expect that classes that implement your interfaces have many common methods or fields, or require access modifiers other than public.

B. You expect that unrelated classes would implement your interfaces.

C. You want to share code among several closely related classes.

D. You want to declare non-static on non-final fields.

E. You want to take advantage of multiple inheritance of type.

Buy Now
Questions 5

Given the code fragment:

String str = "Java is a programming language"; ToIntFunction indexVal = str: : indexOf; //line n1 int x = indexVal.applyAsInt("Java"); //line n2 System.out.println(x);

What is the result?

A. 0

B. 1

C. A compilation error occurs at line n1.

D. A compilation error occurs at line n2.

Buy Now
Questions 6

Given the code fragment:

BiFunction val = (t1, t2) -> t1 + t2; //line n1 System.out.println(val.apply(10, 10.5));

What is the result?

A. 20

B. 20.5

C. A compilation error occurs at line n1.

D. A compilation error occurs at line n2.

Buy Now
Questions 7

Given:

class RateOfInterest {

public static void main (String[] args) {

int rateOfInterest = 0;

String accountType = "LOAN";

switch (accountType) {

case "RD";

rateOfInterest = 5;

break;

case "FD";

rateOfInterest = 10;

break;

default: assert false: "No interest for this account"; //line n1 } System.out.println ("Rate of interest:" + rateOfInterest); } }

and the command:

java -ea RateOfInterest

What is the result?

A. Rate of interest: 0

B. An AssertionError is thrown.

C. No interest for this account

D. A compilation error occurs at line n1.

Buy Now
Questions 8

Given the code fragment:

What is the result?

A. 5 : 3 : 6

B. 6 : 5 : 6

C. 3 : 3 : 4

D. 4 : 4 : 4

Buy Now
Questions 9

Given:

Your design requires that:

fuelLevel of Engine must be greater than zero when the start() method is invoked. The code must terminate if fuelLevel of Engine is less than or equal to zero.

Which code fragment should be added at line n1 to express this invariant condition?

A. assert (fuelLevel) : "Terminating...";

B. assert (fuelLevel > 0) : System.out.println ("Impossible fuel");

C. assert fuelLevel < 0: System.exit(0);

D. assert fuelLevel > 0: "Impossible fuel" ;

Buy Now
Questions 10

Given the code fragment:

What is the result?

A. A compilation error occurs at line n1.

B. Checking...

C. Checking... Checking...

D. A compilation error occurs at line n2.

Buy Now
Questions 11

Assume customers.txt is accessible and contains multiple lines.

Which code fragment prints the contents of the customers.txt file?

A. Stream stream = Files.find (Paths.get ("customers.txt")); stream.forEach((String c) -> System.out.println(c));

B. Stream stream = Files.find (Paths.get ("customers.txt")); stream.forEach( c) -> System.out.println(c));

C. Stream stream = Files.list (Paths.get ("customers.txt")); stream.forEach( c) -> System.out.println(c));

D. Stream lines = Files.lines (Paths.get ("customers.txt")); lines.forEach( c) -> System.out.println(c));

Buy Now
Questions 12

Given the code fragment:

List doubles = Arrays.asList (100.12, 200.32);

DoubleFunction funD = d ?gt; d + 100.0;

doubles.stream (). forEach (funD); // line n1

doubles.stream(). forEach(e ?gt; System.out.println(e)); // line n2

What is the result?

A. A compilation error occurs at line n2.

B. 200.12

300.32

C. 100.12

200.32

D. A compilation error occurs at line n1.

Buy Now
Questions 13

Given the code fragments:

class Caller implements Callable {

String str;

public Caller (String s) {this.str=s;}

public String call()throws Exception { return str.concat ("Caller");}

}

class Runner implements Runnable {

String str;

public Runner (String s) {this.str=s;}

public void run () { System.out.println (str.concat ("Runner"));}

}

and

public static void main (String[] args) throws InterruptedException, ExecutionException { ExecutorService

es = Executors.newFixedThreadPool(2);

Future f1 = es.submit (new Caller ("Call"));

Future f2 = es.submit (new Runner ("Run"));

String str1 = (String) f1.get();

String str2 = (String) f2.get(); //line n1

System.out.println(str1+ ":" + str2);

}

What is the result?

A. The program prints:

Run Runner

Call Caller : null

And the program does not terminate.

B. The program terminates after printing: Run Runner Call Caller : Run

C. A compilation error occurs at line n1.

D. An Execution is thrown at run time.

Buy Now
Exam Code: 1Z0-809
Exam Name: Java SE 8 Programmer II
Last Update: Dec 15, 2024
Questions: 207
10%OFF Coupon Code: SAVE10

PDF (Q&A)

$49.99

VCE

$55.99

PDF + VCE

$65.99