Oracle 1z0-809 - Java SE 8 Programmer II
Given the code fragment:
What is the result?
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?
Which action can be used to load a database driver by using JDBC3.0?
Given the code fragments:
and
What is the result?
Given the code fragment:
Which code fragment, when inserted at line n1, ensures false is printed?
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.add(new Vehicle (10123, “Fordâ€));
vehicles.add(new Vehicle (10124, “BMWâ€));
System.out.println(vehicles);
What is the result?
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!?
Which two statements are true about localizing an application? (Choose two.)
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?
Given:
public interface Moveable
public default void walk (Integer distance) {System.out.println(“Walkingâ€);)
public void run(Integer distance);
}
Which statement is true?