Given:
What is the result?
Show answerHide answer
Correct answer: C
A StringIndexOutOfBoundsException is thrown at runtime.
Java SE 8 Programmer II
Free 1z0-809 mock exam questions 11–20, each with the answer and an explanation.
20 questions · 33 minutes · free, no sign-up
Given:
What is the result?
Correct answer: C
A StringIndexOutOfBoundsException is thrown at runtime.
Given:
public class Foo<K, V> {
private K key;
private V value;
public Foo (K key, V value) (this.key = key; this value = value;)
public static <T> Foo<T, T> twice (T value) (return new Foo<T, T> (value, value); )
public K getKey () (return key;)
public V getValue () (return value;)
}
Which option fails?
Correct answer: C
Foo<?, ?> percentage = new Foo <> (97, 32);
Given the code fragments:
What is the result?
Correct answer: D
Compilation fails at line n2
Given the content of /resourses/Message.properties:
welcome1=”Good day!”
and given the code fragment:
Properties prop = new Properties ();
FileInputStream fis = new FileInputStream (“/resources/Message.properties”);
prop.load(fis);
System.out.println(prop.getProperty(“welcome1”));
System.out.println(prop.getProperty(“welcome2”, “Test”));//line n1
System.out.println(prop.getProperty(“welcome3”));
What is the result?
Correct answer: D
A compilation error occurs at line n1.
Given:
Class A { }
Class B { }
Interface X { }
Interface Y { }
Which two definitions of class C are valid?
Correct answer: A, E
Class C extends A implements X { } Class C extends B implements X, Y { }
extends is for extending a class.
implements is for implementing an interface.
Java allows for a class to implement many interfaces.
Which statement is true about java.util.stream.Stream?
Correct answer: B
The execution mode of streams can be changed during processing.
Given:
interface Rideable {Car getCar (String name); }
class Car {
private String name;
public Car (String name) {
this.name = name;
}
}
Which code fragment creates an instance of Car?
Correct answer: C
Rideable rider = Car : : new;
Car vehicle = rider.getCar(“MyCar”);
Given the code fragments:
class Caller implements Callable<String> {
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?
Correct answer: A
The program prints:
Run Runner
Call Caller : null
And the program does not terminate.
Given:
class Book {
int id;
String name;
public Book (int id, String name) {
this.id = id;
this.name = name;
}
public boolean equals (Object obj) { //line n1
boolean output = false;
Book b = (Book) obj;
if (this.name.equals(b name))}
output = true;
}
return output;
}
}
and the code fragment:
Book b1 = new Book (101, “Java Programing”);
Book b2 = new Book (102, “Java Programing”);
System.out.println (b1.equals(b2)); //line n2
Which statement is true?
Correct answer: C
A compilation error occurs. To ensure successful compilation, replace line n1 with:
boolean equals (Book obj) {
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?
Correct answer: A
Velocity with new speed
Full-length mocks with the same number of questions and the same time limit as the real 1z0-809 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.
Get full 1z0-809 mock exam