Free 1Z0-809 Exam Dumps

Question 26

Given:
1. abstract class Shape {
2. Shape ( ) { System.out.println (“Shape”); }
3. protected void area ( ) { System.out.println (“Shape”); } 4. }
5.
6. class Square extends Shape {
7. int side;
8. Square int side {
9. /* insert code here */
10. this.side = side;
11. }
12. public void area ( ) { System.out.println (“Square”); }
13. }
14. class Rectangle extends Square {
15. int len, br;
16. Rectangle (int x, int y) {
17. /* insert code here */
18. len = x, br = y;
19. }
20. void area ( ) { System.out.println (“Rectangle”); }
21. }
Which two modifications enable the code to compile? (Choose two.)

Correct Answer:DF

Question 27

Given:
public final class IceCream { public void prepare() {}
}
public class Cake {
public final void bake(int min, int temp) {} public void mix() {}
}
public class Shop {
private Cake c = new Cake (); private final double discount = 0.25;
public void makeReady () { c.bake(10, 120); }
}
public class Bread extends Cake {
public void bake(int minutes, int temperature) {} public void addToppings() {}
}
Which statement is true?

Correct Answer:D

Question 28

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?

Correct Answer:A

Question 29

Given the code fragment:
Map books = new TreeMap<>(); books.put (1007, “A”);
books.put (1002, “C”);
books.put (1001, “B”);
books.put (1003, “B”); System.out.println (books); What is the result?

Correct Answer:B

Question 30

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