1Z0-809 Exam Questions
277 real 1Z0-809 exam questions with expert-verified answers and explanations. Page 5 of 6.
- Question #201
Given the code fragments: public static Optional<String> getCountry(String loc) { Optional<String> couName = Optional.empty(); if ("Paris".equals(loc)) couName = Optional.of("Franc...
- Question #202
Given the code fragment: //line n1 System.out.println(IP); Which code fragment, when inserted at line n1, enables the code to print /First.txt?
- Question #203
Given the code fragment: try { Connection conn = DriverManager.getConnection(dbURL, userName, passWord); String query = "SELECT * FROM Employee WHERE ID = 110"; Statement stat = co...
- Question #204
Given the code fragment: public static void main(String[] args) { Console console = System.console(); char[] pass = console.readPassword("Enter password:"); // line n1 String passw...
- Question #205
Locale Currency Symbol Currency Code US $ USD and the code fragment? ``` double d = 15; Locale l = new Locale("en", "US"); NumberFormat formatter = NumberFormat.getCurrencyInstance...
- Question #206
Given the code fragment: ``` Stream<List<String>> strs = Stream.of( Arrays.asList("text1", "text2"), Arrays.asList("text2", "text3")); Stream<String> bs2 = strs .filter(b -> b.cont...
- Question #207
Given: ``` public interface LengthValidator { public boolean checkLength(String str); } ``` and ``` public class Txt { public static void main(String[] args) { boolean res = new Le...
- Question #208
Given: ``` public class Product { public double applyDiscount(double price) { assert (price > 0); // line n1 return price * 0.50; } public static void main(String[] args) { Product...
- Question #209
Given the code fragment: ``` LocalTime now = LocalTime.now(); long timeToBreakfast = 0; LocalTime office_start = LocalTime.of(7, 30); if (office_start.isAfter(now)) { timeToBreakfa...
- Question #210
Given the code fragments: ``` class R implements Runnable { public void run() { System.out.println("Run..."); } } class C implements Callable<String> { public String call() throws...
- Question #211
Which two are elements of a singleton class? (Choose two.)
- Question #212
Given the code fragment: ``` Deque<String> queue = new ArrayDeque<>(); queue.add("Susan"); queue.add("Allen"); queue.add("David"); System.out.println(queue.pop()); System.out.print...
- Question #213
Given: ``` public class Vehicle { int vid; String vName; public Vehicle(int vIdArg, String vNameArg) { this.vid = vIdArg; this.vName = vNameArg; } public int getVId() { return vid;...
- Question #214
Given the code fragment: ``` List<String> valList = Arrays.asList("","George", "", "John", "Jim"); Long newVal = valList.stream() // line n1 .filter(x -> !x.isEmpty()) .count(); //...
- Question #215
Given the code fragment: // Login time:2015-01-12T21:58:18.817Z instant loginTime = Instant.now(); Thread.sleep(1000); // Logout time:2015-01-12T21:58:19.880Z instant logoutTime =...
- Question #216
Given the code fragment: List<String> words = Arrays.asList("win", "try", "best", "luck", "do"); Predicate<String> test1 = w -> { System.out.println("Checking..."); // line n1 retu...
- Question #217
Assume customers.txt is accessible and contains multiple lines. Which code fragment prints the contents of the customers.txt file?
- Question #218
Given: class MyClass implements AutoCloseable { int test; public void close() { } public MyClass copyObject() { return this; } } and the code fragment: MyClass obj = null; try (MyC...
- Question #219
Which two methods from the java.util.stream.Stream interface perform a reduction operation? (Choose two.)
- Question #220
Which code fragment is required to load a JDBC 3.0 driver?
- Question #221
Given the definition of the Emp class: public class Emp { private String eName; private Integer eAge; Emp(String eN, Integer eA) { this.eName = eN; this.eAge = eA; } public Integer...
- Question #222
Given the code fragment: List<Integer> prices = Arrays.asList(3, 4, 5); prices.stream() .filter(e -> e > 4) .peek(e -> System.out.print ("Price " + e)) // line n1 .map(e -> e + 1)...
- Question #223
Given the definition of the Book class: public class Book { private int id; private String name; public Book(int id, String name) {this.id = id; this.name = name;} public int getId...
- Question #224
You have been asked to define the ProductCode class. The definition of the ProductCode class must allow c1 instantiation to succeed and cause a compilation error on c2 instantiatio...
- Question #225
Given the code fragment: Map<Integer, Integer> mVal = new HashMap<>(); mVal.put(1, 10); mVal.put(2, 20); //line n1 c.accept(1, 2); mVal.forEach(c); Which statement can be inserted...
- Question #226
Given the code fragment: ```java List<String> nums = Arrays.asList("EE", "SE", "SE"); String ans = nums .parallelStream() .reduce("Java ", (a, b) -> a.concat(b)); System.out.print(...
- Question #227
Given the code fragments: ```java public class Product { String name; Integer price; Product(String name, Integer price) { this.name = name; this.price = price; } public void print...
- Question #228
Given: ```java interface P { public void method1(); } interface Q extends P { public void method1(); } interface R extends P { public void method2(); } interface S { public default...
- Question #229
Given the code fragment: ```java final List<String> list = new CopyOnWriteArrayList<>(); final AtomicInteger ai = new AtomicInteger(0); final CyclicBarrier barrier = new CyclicBarr...
- Question #230
Given that these files exist and are accessible: `/company/emp/info.txt` `/company/emp/benefits/b1.txt` and given the code fragment: ```java // line n1 stream.forEach(s -> System.o...
- Question #231
Which class definition compiles?
- Question #232
Given the code fragment: ```java Deque<Integer> nums = new ArrayDeque<>(); nums.add(1000); nums.push(2000); nums.add(3000); nums.add(4000); Integer i1 = nums.remove(); Integer i2 =...
- Question #233
Given that `version.txt` is accessible and contains: `1234567890` and given the code fragment: ```java try (FileInputStream fis = new FileInputStream("version.txt"); InputStreamRea...
- Question #234
7. BiPredicate<String, String> bp = (String s1, String s2) -> s1.contains("SG") && 8. s2.contains("Java"); 9. BiFunction<String, String, Integer> bf = (String s1, String s2) -> { 1...
- Question #235
Given the content: MessagesBundle.properties file: inquiry = How are you? MessagesBundle_de_DE.properties file: inquiry = Wie geht's? and given the code fragment: Locale currentLoc...
- Question #236
Given the code fragment: List<String> gwords = Arrays.asList("why ", "what ", "when "); BinaryOperator<String> operator = (s1, s2) -> s1.concat(s2); // line n1 String sen = gwords....
- Question #237
Given: interface Interface1 { public default void sayHi() { System.out.println("Hi Interface-1"); } } interface Interface2 { public default void sayHi() { System.out.println("Hi In...
- Question #238
Given: class Block { String color; int size; Block(int size, String color) { this.size = size; this.color = color; } } and the code fragment: List<Block> blocks = new ArrayList<>()...
- Question #239
public static void main(String[] args) { Stream.of("Java", "Unix", "Linux") .filter(s -> s.contains("n")) .peek(s -> System.out.println("PEEK: " + s)) // line n1 } Which two code f...
- Question #240
Given the code fragments: class Person // line n1 { String name; Person(String name) { this.name = name; } } // line n2 and List<Person> emps = new ArrayList<>(); // code that adds...
- Question #241
Given: class Person { private String firstName; private int salary; public Person(String fN, int sal) { this.firstName = fN; this.salary = sal; } public int getSalary() { return sa...
- Question #242
Connection con = null; try { // line n1 if (con != null) { System.out.print("Connection Established."); } } catch (Exception e) { System.out.print(e); } Assume that dbURL, userName...
- Question #243
Given the greetings.properties file, containing: HELLO_MSG = Hello, everyone! GOODBYE_MSG = Goodbye everyone! and given: import java.util.Enumeration; import java.util.Locale; impo...
- Question #244
Given the code fragments: public class Test { List<String> list = null; public void printValues() { System.out.print(getList()); } public List<String> getList() { return list; } pu...
- Question #245
Given the records from the STUDENT table: sid sname semail 111 James [email protected] 112 Jane [email protected] 114 John [email protected] Given the code fragment: public static void main(Stri...
- Question #246
Given the code fragment: 5. IntConsumer consumer = e -> System.out.println(e); 6. Integer value = 90; 7. /* insert code fragment here */ 8. consumer.accept(result); Which code frag...
- Question #247
Which two statements are true about the Fork/Join Framework? (Choose two.)
- Question #248
Which two statements are true about synchronization and locks? (Choose two.)
- Question #249
Given the code fragment: //line n1 double d = str.average().getAsDouble(); System.out.println("Average = " + d); Which should be inserted into line n1 to print Average = 2.5?
- Question #250
Given the structure of the Student table: Student (id INTEGER, name VARCHAR) Given the records from the STUDENT table: ID NAME 102 Edwin 103 Edward 103 Edwin Given the code fragmen...