Oracle 1z0-809 - Java SE 8 Programmer II
Given the code fragment:
Assume that dbURL, userName, and password are valid.
Which code fragment can be inserted at line n1 to enable the code to print Connection Established?
Given:
public class Canvas implements Drawable {
public void draw () { }
}
public abstract class Board extends Canvas { }
public class Paper extends Canvas {
protected void draw (int color) { }
}
public class Frame extends Canvas implements Drawable {
public void resize () { }
}
public interface Drawable {
public abstract void draw ();
}
Which statement is true?
Given the code fragment:
List
Function
nL.Stream()
.map(funVal)
.peek(System.out::print);
What is the result?
Given:
public class Test
private T t;
public T get () {
return t;
}
public void set (T t) {
this.t = t;
}
public static void main (String args [ ] ) {
Test
Test type 1 = new Test ();//line n1
type.set(“Javaâ€);
type1.set(100);//line n2
System.out.print(type.get() + “ “ + type1.get());
}
}
What is the result?
Given the code fragments:
4. void doStuff() throws ArithmeticException, NumberFormatException, Exception {
5. if (Math.random() >-1 throw new Exception (“Try againâ€);
6. }
and
24. try {
25. doStuff ( ):
26. } catch (ArithmeticException | NumberFormatException | Exception e) {
27. System.out.println (e.getMessage()); }
28. catch (Exception e) {
29. System.out.println (e.getMessage()); }
30. }
Which modification enables the code to print Try again?
Which statement is true about java.util.stream.Stream?
Given the code fragment:
Path file = Paths.get (“courses.txtâ€);
// line n1
Assume the courses.txt is accessible.
Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?
Given:
class Vehicle {
int vno;
String name;
public Vehicle (int vno, String name) {
this.vno = vno,;
this.name = name;
}
public String toString () {
return vno + “:†+ 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 the code fragment:
Path path1 = Paths.get(“/app/./sys/â€);
Path res1 = path1.resolve(“logâ€);
Path path2 = Paths.get(“/server/exe/â€);
Path res1 = path2.resolve(“/readme/â€);
System.out.println(res1);
System.out.println(res2);
What is the result?
Given the code fragment:
What is the result?