Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-809
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-809.html
Java SE 8 Programmer II
Question No: 11
Given:
public class product {
int id; int price;
public Product (int id, int price) { this.id = id;
this.price = price;
}
public String toString() { return id “:” price; }
}
and the code fragment:
Listlt;Productgt; products = Arrays.asList(new Product(1, 10), new Product (2, 30),
new Product (2, 30));
Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -gt; { p1.price =p2.price;
return new Product (p1.id, p1.price);}); products.add(p); products.stream().parallel()
.reduce((p1, p2) – gt; p1.price gt; p2.price ? p1 : p2)
.ifPresent(System.out: :println); What is the result?
A. 2 : 30
B. 4 : 0
C. 4 : 60
D. 4 : 60
2 : 30
3 : 20
1 : 10
The program prints nothing.
Answer: D
Question No: 12
Given the code fragment:
Listlt;Integergt; values = Arrays.asList (1, 2, 3); values.stream ()
.map(n -gt; n*2)//line n1
.peek(System.out::print)//line n2
.count();
What is the result?
A. 246
-
The code produces no output.
-
A compilation error occurs at line n1.
-
A compilation error occurs at line n2.
Answer: A
Question No: 13
Given the code fragments:
What is the result?
-
Super Sub
Sub
-
Contract Contract Super
-
Compilation fails at line n1
-
Compilation fails at line n2
Answer: D
Question No: 14
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?
-
Good day!
Test
followed by an Exception stack trace
-
Good day!
followed by an Exception stack trace
-
Good day!
Test null
-
A compilation error occurs at line n1.
Answer: D
Question No: 15
Given:
Class A { } Class B { }
Interface X { } Interface Y { }
Which two definitions of class C are valid?
-
Class C extends A implements X { }
-
Class C implements Y extends B { }
-
Class C extends A, B { }
-
Class C implements X, Y extends B { }
-
Class C extends B implements X, Y { }
Answer: A,E
Explanation: extends is for extending a class.
implements is for implementing an interface.
Java allows for a class to implement many interfaces.
Question No: 16
Which statement is true about java.util.stream.Stream?
-
A stream cannot be consumed more than once.
-
The execution mode of streams can be changed during processing.
-
Streams are intended to modify the source data.
-
A parallel stream is always faster than an equivalent sequential stream.
Answer: B
Question No: 17
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?
-
Car auto = Car (“MyCar”): : new;
-
Car auto = Car : : new;
Car vehicle = auto : : getCar(“MyCar”);
-
Rideable rider = Car : : new;
Car vehicle = rider.getCar(“MyCar”);
-
Car vehicle = Rideable : : new : : getCar(“MyCar”);
Answer: C
Question No: 18
Given the code fragments:
class Caller implements Callablelt;Stringgt; { 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?
-
The program prints: Run Runner
Call Caller : null
And the program does not terminate.
-
The program terminates after printing: Run Runner
Call Caller : Run
-
A compilation error occurs at line n1.
-
An Execution is thrown at run time.
Answer: A
Question No: 19
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?
-
The program prints true.
-
The program prints false.
-
A compilation error occurs. To ensure successful compilation, replace line n1 with: boolean equals (Book obj) {
-
A compilation error occurs. To ensure successful compilation, replace line n2 with: System.out.println (b1.equals((Object) b2));
Answer: C
Question No: 20
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?
-
Velocity with new speed
-
A compilation error occurs at line n1.
-
A compilation error occurs at line n2.
-
A compilation error occurs at line n3.
Answer: A
100% Ensurepass Free Download!
–Download Free Demo:1z0-809 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-809 Dumps
EnsurePass | ExamCollection | Testking | |
---|---|---|---|
Lowest Price Guarantee | Yes | No | No |
Up-to-Dated | Yes | No | No |
Real Questions | Yes | No | No |
Explanation | Yes | No | No |
PDF VCE | Yes | No | No |
Free VCE Simulator | Yes | No | No |
Instant Download | Yes | No | No |
100-105 Dumps VCE PDF
200-105 Dumps VCE PDF
300-101 Dumps VCE PDF
300-115 Dumps VCE PDF
300-135 Dumps VCE PDF
300-320 Dumps VCE PDF
400-101 Dumps VCE PDF
640-911 Dumps VCE PDF
640-916 Dumps VCE PDF
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF
220-901 Dumps VCE PDF
220-902 Dumps VCE PDF
N10-006 Dumps VCE PDF
SY0-401 Dumps VCE PDF