Weekend Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmas50

Oracle 1z0-809 - Java SE 8 Programmer II

Page: 3 / 6
Total 196 questions

Given the code fragment:

What is the result?

A.

A compilation error occurs at line n1.

B.

Logged out at: 2015-01-12T21:58:19.880Z

C.

Can’t logout

D.

Logged out at: 2015-01-12T21:58:00Z

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) 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 RunnerCall Caller : nullAnd the program does not terminate.

B.

The program terminates after printing:Run RunnerCall Caller : Run

C.

A compilation error occurs at line n1.

D.

An Execution is thrown at run time.

Which action can be used to load a database driver by using JDBC3.0?

A.

Add the driver class to the META-INF/services folder of the JAR file.

B.

Include the JDBC driver class in a jdbc.properties file.

C.

Use the java.lang.Class.forName method to load the driver class.

D.

Use the DriverManager.getDriver method to load the driver class.

Given the code fragments:

and

What is the result?

A.

Video played.Game played.

B.

A compilation error occurs.

C.

class java.lang.Exception

D.

class java.io.IOException

Given the code fragment:

Which code fragment, when inserted at line n1, ensures false is printed?

A.

boolean b = cs.stream() .findAny() .get() .equals(“Java”);

B.

boolean b = cs.stream() .anyMatch (w -> w.equals (“Java”));

C.

boolean b = cs.stream() .findFirst() .get() .equals(“Java”);

D.

boolean b = cs.stream() .allMatch(w -> w.equals(“Java”));

Given:

class Vehicle implements Comparable{

int vno;

String name;

public Vehicle (int vno, String name) {

this.vno = vno,;

this.name = name;

}

public String toString () {

return vno + “:” + name;

}

public int compareTo(Vehicle o) {

return this.name.compareTo(o.name);

}

and this code fragment:

Set vehicles = new TreeSet <> ();

vehicles.add(new Vehicle (10123, “Ford”));

vehicles.add(new Vehicle (10124, “BMW”));

System.out.println(vehicles);

What is the result?

A.

[10123:Ford, 10124:BMW]

B.

[10124:BMW, 10123:Ford]

C.

A compilation error occurs.

D.

A ClassCastException is thrown at run time.

Given:

class FuelNotAvailException extends Exception { }

class Vehicle {

void ride() throws FuelNotAvailException {//line n1

System.out.println(“Happy Journey!”);

}

}

class SolarVehicle extends Vehicle {

public void ride () throws Exception {//line n2

super ride ();

}

}

and the code fragment:

public static void main (String[] args) throws FuelNotAvailException, Exception {

Vehicle v = new SolarVehicle ();

v.ride();

}

Which modification enables the code fragment to print Happy Journey!?

A.

Replace line n1 with public void ride() throws FuelNotAvailException {

B.

Replace line n1 with protected void ride() throws Exception {

C.

Replace line n2 with void ride() throws Exception {

D.

Replace line n2 with private void ride() throws FuelNotAvailException {

Which two statements are true about localizing an application? (Choose two.)

A.

Support for new regional languages does not require recompilation of the code.

B.

Textual elements (messages and GUI labels) are hard-coded in the code.

C.

Language and region-specific programs are created using localized data.

D.

Resource bundle files include data and currency information.

E.

Language codes use lowercase letters and region codes use uppercase letters.

Given the definition of the Vehicle class:

Class Vehhicle {

int distance;//line n1

Vehicle (int x) {

this distance = x;

}

public void increSpeed(int time) {//line n2

int timeTravel = time;//line n3

class Car {

int value = 0;

public void speed () {

value = distance /timeTravel;

System.out.println (“Velocity with new speed”+value+”kmph”);

}

}

new Car().speed();

}

}

and this code fragment:

Vehicle v = new Vehicle (100);

v.increSpeed(60);

What is the result?

A.

Velocity with new speed

B.

A compilation error occurs at line n1.

C.

A compilation error occurs at line n2.

D.

A compilation error occurs at line n3.

Given:

public interface Moveable {

public default void walk (Integer distance) {System.out.println(“Walking”);)

public void run(Integer distance);

}

Which statement is true?

A.

Moveable can be used as below:Moveable animal = n - > System.out.println(“Running” + n);animal.run(100);animal.walk(20);

B.

Moveable can be used as below:Moveable animal = n - > n + 10;animal.run(100);animal.walk(20);

C.

Moveable can be used as below:Moveable animal = (Integer n) - > System.out.println(n);animal.run(100);Moveable.walk(20);

D.

Movable cannot be used in a lambda expression.