Sign In
Home/Oracle/1z0-809/Free questions

1z0-809 — Free Practice Questions

10 free sample questions from a bank of 213, with the correct answers and explanations. No signup required — start practising right now.

1Given: IntStream stream = IntStream.of (1,2,3); IntFunction inFu= x -> y -> x*y; //line n1 IntStream newStream = stream.map(inFu.apply(10)); //line n2 newStream.forEach(System.output::print); Which modification enables the code fragment to compile? line n1 with:
  • Replace IntFunction inFu = x -> y -> x*y; line n1 with:
  • Replace IntFunction inFu = x -> y -> x*y; line n1 with:
  • Replace BiFunction inFu = x -> y -> x*y; line n2 with:
  • Replace
Answer: D
2Given 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 -
  • line n1.
  • A compilation error occurs at line n2.
  • A compilation error occurs at line n3.
  • A compilation error occurs at
Answer: A
3Given the definition of the Vehicle class: Class Vehicle { int distance; Vehicle (int x) { this distance = x; } public void increSpeed(int time) { int timeTravel = time; //line n1 //line n3 class Car { int value = 0; public void speed () { value = distance /timeTravel; //line n2 System.out.println ("Velocity with new speed"+value+"kmph"); } } speed(); //line n3 } } and this code fragment: Vehicle v = new Vehicle (100); v.increSpeed(60); What is the result?
  • Velocity with new speed 1 kmph
  • A compilation error occurs at line n1.
  • A compilation error occurs at line n2.
  • A compilation error occurs at line n3.
Answer: D
4Given the code fragment: Path source = Paths.get ("/data/december/log.txt"); Path destination = Paths.get("/data"); Files.copy (source, destination); /data/december/log.txt is accessible and contains: and assuming that the file 10-Dec-2014 Executed successfully What is the result? log.txt is created in the /data directory and the content of the /data/december/log.txt file is copied to it.
  • A file with the name
  • The program executes successfully and does NOT change the file system. FileNotFoundException is thrown at run time.
  • A FileAlreadyExistsException is thrown at run time.
  • A
Answer: B
5Given the content of Operator.java, EngineOperator.java, and Engine.java files: and the code fragment: What is the result?
1z0-809 question 51z0-809 question 5
  • The Engine.java file fails to compile.
  • The EngineOperator.java file fails to compile.
  • The Operator.java file fails to compile.
  • ON OFF
Answer: C
6Given the code fragment: Which code fragment, when inserted at line n1, ensures false is printed?
1z0-809 question 6
  • boolean b = cs.stream() .findAny() .get() .equals("Java");
  • boolean b = cs.stream() .anyMatch (w -> w.equals ("Java"));
  • boolean b = cs.stream() .findFirst() .get() .equals("Java");
  • boolean b = cs.stream() .allMatch(w -> w.equals("Java"));
Answer: D
7Given the code fragment: What is the result?
1z0-809 question 7
  • A compilation error occurs at line n1.
  • courseJava
  • Javacourse
  • A compilation error occurs at line n2.
Answer: D
8Given: Your design requires that: ✑ fuelLevel of Engine must be greater than zero when the start() method is invoked. ✑ The code must terminate if fuelLevel of Engine is less than or equal to zero. Which code fragment should be added at line n1 to express this invariant condition?
1z0-809 question 8
  • assert (fuelLevel) : "Terminating"¦";
  • assert (fuelLevel > 0) : System.out.println ("Impossible fuel");
  • assert fuelLevel < 0: System.exit(0);
  • assert fuelLevel > 0: "Impossible fuel" ;
Answer: D
9Given the code fragments: and What is the result?
1z0-809 question 91z0-809 question 9
  • France Optional[NotFound]
  • Optional [France] Optional [NotFound]
  • Optional[France] Not Found
  • France Not Found
Answer: D
10Given the code fragment: Which code fragment, when inserted at line n1, enables the code to print /First.txt?
1z0-809 question 10
  • Path iP = new Paths ("/First.txt");
  • Path iP = Paths.toPath ("/First.txt");
  • Path iP = new Path ("/First.txt");
  • Path iP = Paths.get ("/", "First.txt");
Answer: D

Want the full bank of 213 questions for 1z0-809? See all practice exams.