1Z0-809 Exam Questions
277 real 1Z0-809 exam questions with expert-verified answers and explanations. Page 1 of 6.
- Question #1
Given that /green.txt and /colors/yellow.txt are accessible, and the code fragment: ```java Path source = Paths.get("/green.txt"); Path target = Paths.get("/colors/yellow.txt"); Fi...
- Question #2
Given the class definitions: ```java class Alpha { public String doStuff(String msg) { return msg; } } class Beta extends Alpha { public String doStuff(String msg) { return msg.rep...
- Question #3
Given the code fragment: ```java BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; //line n1 System.out.println(val.apply(10, 10.5)); //line n2 ``` What is the result...
- Question #4
Given the code fragment: ```java List<Integer> values = Arrays.asList(1, 2, 3); values.stream() .map(n -> n*2)//line n1 .peek(System.out.println)//line n2 .count(); ``` What is the...
- Question #5
What is the proper way to defined a method that take two int values and returns their sum as an int value?
- Question #6
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 ("...
- Question #7
Given the code fragments: class TechName { String techName; TechName (String techName) { this.techName=techName; } } and List<TechName> tech = Arrays.asList ( new TechName("Java"),...
- Question #8
Given: Class A { } Class B { } Interface X { } Interface Y { } extends is for extending a class. implements is for implementing an interface. Java allows for a class to implement m...
- Question #9
A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the results?
- Question #10
Given the code fragment: public class FileThread implements Runnable { String fName; public FileThread (String fName) { this.fName = fName; } public void run () { System.out.printl...
- Question #11
Given: //line n2 public void open() { System.out.println("Open"); } } public class Test { public static void main (String [] args) throws Exception { try (Folder f = new Folder())...
- Question #12
Given the code fragment: List<Integer> codes = Arrays.asList(10, 20); UnaryOperator<Double> uo = s -> s +10.0; codes.replaceAll(uo); codes.forEach(C -> System.out.println(C)); What...
- Question #13
Given: public class Emp { String fName; String lName; public Emp (String fn, String ln) { fName = fn; lName = ln; } public String getfName() { return fName; } public String getlNam...
- Question #14
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...
- Question #15
Given: public final class Cream { public void prepare() { } } public class Cake extends Cream{ public public void bake(int min, int temp) {} public void mix() {} } public class Sho...
- Question #16
You want to create a singleton class by using the Singleton design pattern. Which two statements enforce the singleton nature of the design?
- Question #17
You have been asked to create a ResourceBundle which uses a properties file to localize an application. Which code example specifies valid keys of menu1 and menu2 with values of Fi...
- Question #18
Given the code fragment: public class StringReplace { public static void main(String[] args) { String message = "Hi everyone!"; System.out.println("message = " + message.replace("e...
- Question #19
Given the code fragment: UnaryOperator<Integer> uol = s -> s*2;line n1 List<Double> loanValues = Arrays.asList(1000.0, 2000.0); loanValues.stream() .filter(lv -> lv <= 1500) .map(l...
- Question #20
Given the code fragment: List<String> str = Arrays.asList("my", "pen", "is", "your", "pen"); Predicate<String> test = s -> { int i = 0; boolean result = s.contains ("pen"); System....
- Question #21
Given the code fragment: public static void main (String [ ] args) throws IOException { BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); System.out.print...
- Question #22
Given: public class Canvas implements Drawable { public public void draw () { } } public abstract class Board extends Canvas { } public class Paper extends Canvas { protected void...
- Question #23
Given the code fragment: List<Integer> list1 = Arrays.asList(10, 20); List<Integer> list2 = Arrays.asList(15, 30); //line n1 Which code fragment, when inserted at line n1, prints 1...
- Question #24
Given: public class ScopeTest { int j, int k; public static void main(String[] args) { ew ScopeTest().doStuff(); } void doStuff1() { int x = 5; doStuff2(); System.out.println("x");...
- Question #25
Given the code fragment: class CallerThread implements Callable<String> { String str; public CallerThread(String s) {this.str=s;} public String call() throws Exception { return str...
- Question #26
public class Test { public static Connection newConnection =null; public static Connection getConnection () throws SQLException { try (Connection con = DriverManager.getConnection(...
- Question #27
Given the code fragment: LocalDate valentinesDay = LocalDate.of(2015, Month.FEBRUARY, 14); LocalDate next15Days = valentinesDay.plusDays(15); LocalDate nextYear = next15Days.plusYe...
- Question #28
Given the records from the Employee table: eid ename 111 Tom 112 Jerry 113 Donald and given the code fragment: try { Connection conn = DriverManager.getConnection(URL, userName, pa...
- Question #29
Which action can be used to load a database driver by using JDBC3.0?
- Question #30
Given the fragments: public class TestA extends Root { public static void main (String[] args) { Root r = new TestA(); System.out.println(r.method1()); // line n1 System.out.printl...
- Question #31
Which two items can legally be contained within a java class declaration?
- Question #32
Which statement is true about java.time.Duration?
- Question #33
Given: public class MyFor3 { public static void main(String[] args) { int[] xx = null; for (int ii : xx) { System.out.println(ii); } } } What is the result?
- Question #34
Which two reasons should you use interfaces instead of abstract classes?
- Question #35
Which statement is true about the DriverManager class?
- Question #36
Given the content of /resourses/Message.properties: welcome1="Good day!" and given the code fragment: Properties prop = new Properties (); FileInputStream fis = new FileInputStream...
- Question #37
List<String> colors = Arrays.asList("red", "green", "yellow"); Predicate<String> test = n -> { System.out.println("searching" + n); return n.contains("red"); }; colors.stream() .fi...
- Question #38
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; } } an...
- Question #39
Given: EBook.java: public class EBook extends Book { public String read (String url) { return "View" + url } } Test.java: public class Test { public static void main (String[] args...
- Question #40
Given the code fragments: class MyThread implements Runnable { private static AtomicInteger count = new AtomicInteger (0); public void run () { int x = count.incrementAndGet(); Sys...
- Question #41
Which three statements are benefits of encapsulation?
- Question #42
Given the code fragment: ZonedDateTime departure = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneId.of("UTC-5")); ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, Z...
- Question #43
Given the for loop construct: for ( expr1 ; expr2 ; expr3 ) { statement; } Which two statements are true?
- Question #44
Given: interface Doable { public void doSomething (String s); } Which two class definitions compile?
- Question #45
Given the code fragments: 4. void doStuff() throws ArithmeticException, NumberFormatException, Exception { 5. if (Math.random() >-1 throw new Exception ("Try again"); 6. } and 24....
- Question #46
Which statement is true about the single abstract method of the java.util.function.Function interface?
- Question #47
Given the code fragment: public static void main (String[] args) throws IOException { BufferedReader bRcopy = null; try (BufferedReader bR = new BufferedReader (new FileReader ("em...
- Question #48
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 {...
- Question #49
Given: class Bird { public void fly () { System.out.print ("Can fly"); } } class Penguin extends Bird { public void fly () { System.out.print ("Cannot fly"); } } and the code fragm...
- Question #50
Given that course.txt is accessible and contains: Course : Java and given the code fragment: public static void main (String[ ] args) { char i; try (FileInputStream fis = new FileI...