1Z0-809 Exam Questions
277 real 1Z0-809 exam questions with expert-verified answers and explanations. Page 3 of 6.
- Question #101
Which action encapsulates the Vehicle class?
- Question #102
Given the code fragment: ```java int i = 0; do { i++; } while (i < 0); System.out.println("Out of limits"); ``` What is the result?
- Question #103
Given the code fragment: ```java List<String> empDetails = Arrays.asList("^100, Robin, HR", "^200, Mary, AdminServices", "^101, Peter, HR"); empDetails.stream() .filter(s-> s.conta...
- Question #104
Given: ```java public interface Moveable<Integer> { public default void walk (Integer distance) { System.out.println("Walking")); } public void run(Integer distance); } ``` Which s...
- Question #105
Given: ```java public class Customer { private String fName; private String lName; private static int count; public Customer (String first, String last) {fName = first; lName = las...
- Question #106
Given the code fragment: ```java int [] lst = {1, 2, 3, 4, 5, 3, 2, 1}; int sum = 0; for (int frnt = 0, rear = lst.length - 1; frnt < 5 && rear >= 0; frnt++, rear--) { sum = sum +...
- Question #107
Given: ```java public class Calculator { public static void main(String[] args) { int num = 5; int sum; do { sum += num; } while ( (num--) > 1); System.out.println("The sum is " +...
- Question #108
Given the code fragment: ```java List<String> codes= Arrays.asList("DOC", "MPEG", "JPEG"); codes.forEach(c -> System.out.print(c + " ")); String mt = codes.stream() .filter(s-> s.c...
- Question #109
Given: ```java IntStream stream = IntStream.of(1,2,3); IntFunction<Integer> inFu = x -> x * x;//line n1 IntStream newStream = stream.map(inFu.apply(10));//line n2 newStream.forEach...
- Question #110
Given the code fragment: ```java class UserException extends Exception { } class AgeOutOfLimitException extends UserException { } ``` And the code fragment: ```java class App { pub...
- Question #111
Given the class definitions: ```java class ImageScanner implements AutoCloseable { public void close () throws Exception { System.out.println ("Scanner closed."); } public void sca...
- Question #112
Scan.Printer file = new Scan.Printer(); Scan.Scanner scanner = new Scan.Scanner(file); scanner.scan(); What is the result?
- Question #113
For which three objects must a vendor provide implementations in its JDBC driver?
- Question #114
Given: public class MainMethod { void main() { System.out.println("one"); } static void main(String args) { System.out.println("two"); } public static void main(String[] args) { Sy...
- Question #115
Which two code blocks correctly initialize a Locale variable?
- Question #116
Given the code fragment: List<Integer> nums = Arrays.asList( 10, 20, 8); System.out.println ( // line n1 ); Which code fragment must be inserted at line n1 to enable the code to pr...
- Question #117
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 t...
- Question #118
Given the code fragments: public class Book implements Comparator<Book> { String name; double price; public Book () { } public Book (String name, double price) { this.name = name;...
- Question #119
Given: package p1; public interface DoInterface { void m1(int n); public void m2(int n); } package p3; import p1.DoInterface; public class DoClass implements DoInterface { int x1,...
- Question #120
Given: public class Test<T> { private T t; public T get () { return t; } public void set (T t) { this.t = t; } } public static void main (String args [ ] ) { Test<String> type = ne...
- Question #121
Which two are Java Exception classes?
- Question #122
Which statement is true about Java byte code?
- Question #123
Which two are benefits of polymorphism?
- Question #124
Given: public class Data { private int x; public Data(int x) { this.x = x; } public int getX() { return x; } } public class Test { public static void main(String[] args) { List<Dat...
- Question #125
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
- Question #126
Which statement best describes encapsulation?
- Question #127
Which statement is true about the switch statement?
- Question #128
class Vehicle { int x; Vehicle() { this(10); // line n1 } Vehicle(int x) { this.x = x; } } class Car extends Vehicle { int y; Car() { super(); // line n2 this(20); } Car(int y) { t...
- Question #129
Given the code fragment: 7. StringBuilder sb1 = new StringBuilder("Duke"); 8. String str1 = sb1.toString(); 9. // insert code here 10. System.out.print(str1 == str2); Which code fr...
- Question #130
Given the code fragment: class X { public void printFileContent () { /* code goes here */ throw new IOException(); } public class Test { public static void main (String [] args) {...
- Question #131
Given the code fragment: 1. public class Test { 2. public static void main (String[] args) { 3. // insert code here 4. array[0]=10; 5. array[1]=20; 6. System.out.print(array[0]+":"...
- Question #132
Given the code fragment: class Student { String name; int age; } And, public class Test { public static void main(String[] args) { Student s1 = new Student(); Student s2 = new Stud...
- Question #133
Given the code fragment: public static void main(String[] args) { String[] arr = {"A", "B", "C", "D"}; for (int i = 0; i < arr.length; i++) { System.out.println(arr[i] + " "); if (...
- Question #134
Given the code fragment: public static void main(String[] args) { String date = LocalDate.parse("2014-05-04", DateTimeFormatter.ISO_DATE_TIME).toString(); System.out.println(date);...
- Question #135
Given: ```java public class App { public static void main(String[] args) { int i = 10; int j = 20; int k = i++ + j / 5 + i; System.out.print(i + ":" + j + ":" + k); } } ``` What is...
- Question #136
Given: ```java class Test { int al; public static void doProduct(int a) { a = a * a; } public static void doString(StringBuilder s) { s.append(" " + s); } public static void main(S...
- Question #137
Given: ```java public class Test { public static void main(String[] args) { Test test = new Test(); System.out.print(isAvailable + " "); test.isAvailable = true; System.out.println...
- Question #138
Given the code fragment: ```java public static void main(String[] args) { int[] arr = {1, 2, 3, 4}; int i = 0; do { System.out.print(arr[i] + " "); i++; } while (i < arr.length - 1...
- Question #139
Given the code fragment: ```java public static void main(String[] args) { int j = 0; int ii = 7; for (int i = 0; i < ii; i = i + 2) { j = j + i; } System.out.print(ii + " " + j); }...
- Question #140
Given: ```java public class Test { public static void main(String[] args) { if (args.length > 0 && args[0].equals("Hello")) { System.out.println("Success"); } else { System.out.pri...
- Question #141
Given: ```java class MyField { int x, y; public void doStuff(int x, int y) { this.x = x; this.y = y; } public void display() { System.out.println(x + ":" + y + " "); } public stati...
- Question #142
Given the code fragment: ```java public static void main(String[] args) { String[] arr = {"A", "B", "C", "D", "you"}; List<String> arrList = new ArrayList<>(Arrays.asList(arr)); if...
- Question #143
Given: ```java class Vehicle { String type; int maxSpeed = 100; Vehicle(String type, int maxSpeed) { this.type = type; this.maxSpeed = maxSpeed; } } class Car extends Vehicle { Str...
- Question #144
Given the following code for a planet object: ```java public class Planet { public String name; public int moons; public Planet(String name, int moons) { this.name = name; this.moo...
- Question #145
class Alpha { int ns; static int s; Alpha(int ns) { if (s == ns) this.ns = ns; } void doPrint() { System.out.println("ns = " + ns + " s = " + s); } } And, public class TestA { publ...
- Question #146
Given the code fragment: 13. list colors = new ArrayList<>(); 14. colors.add("green"); 15. colors.add("red"); 16. colors.add("blue"); 17. colors.add("yellow"); 18. colors.remove(2)...
- Question #147
Given the code fragment: public static void main(String[] args) { LocalDate date = LocalDate.of(2012, 01, 32); date.plusDays(10); System.out.println(date); } What is the result?
- Question #148
Given the following classes: public class Employee { public int salary; } public class Manager extends Employee { public int budget; } public class Director extends Manager { publi...
- Question #149
Given: public class Test { int x, y; public Test(int x, int y) { initialize(x, y); } public void initialize(int x, int y) { this.x = x * x; this.y = y * y; } public static void mai...
- Question #150
Given: MainTest.java: public class MainTest { public static void main(int[] args) { System.out.println("int main " + args[0]); } public static void main(Object[] args) { System.out...