1Z0-809 Exam Questions
277 real 1Z0-809 exam questions with expert-verified answers and explanations. Page 4 of 6.
- Question #151
Given: class Animal { String type = "Canine"; int maxSpeed = 60; Animal () {} Animal(String type, int maxSpeed) { this.type = type; this.maxSpeed = maxSpeed; } } class WildAnimal e...
- Question #152
Given: class C2 { public void displayC2() { System.out.println("C2"); } } interface I { public void display(); } class C1 extends C2 implements I { public void display() { System.o...
- Question #153
Given the code fragment: public static void main(String[] args) { Integer s1 = 1_000; Integer s2 = 2_000; Long s3 = (long)(s1 + s2); //line n1 String s4 = (String)(s3 + s2); //line...
- Question #154
What is the result?
- Question #155
Given the code fragment: public class Test { public static void main(String[] args) { StringBuilder sb = new StringBuilder(5); String s = ""; if (sb.equals(s)) { System.out.println...
- Question #156
Given the code fragment: public class Test { void readCard(int cardNo) throws Exception { System.out.println("Reading Card"); } void checkCard(int cardNo) throws RuntimeException {...
- Question #157
Given: class A { public A() { System.out.print("A "); } } class B extends A { public B() { System.out.print("B "); //line n1 } } class C extends B { public C() { System.out.print("...
- Question #158
Given the following class: public class Rectangle { private double length; private double height; private double area; public void setLength(double length) { this.length = length;...
- Question #159
Given the code fragment: public class Test { static int count = 0; int i = 0; public void changeCount() { while (i < 5) { count++; i++; } } public static void main(String[] args) {...
- Question #160
The following grid shows the state of a 2D array: O X O O O X X O X This grid is created with the following code: char[][] grid = new char[3][3]; grid[0][0] = 'O'; grid[0][1] = 'X'...
- Question #161
Given the code fragment: int nums1[] = new int [3]; int nums2[] = {1, 2, 3, 4, 5}; nums1 = nums2; for (int x : nums1) { System.out.print(x + ":"); } What is the result?
- Question #162
Given: Acc.java: package p1; public class Acc { int p; private int r; protected int q; public int s; } Test.java: package p2; import p1.Acc; public class Test extends Acc { public...
- Question #163
Given the code fragment: public static void main(String[] args) { int array[] = {10, 20, 30, 40, 50}; int x = array.length; // line n1 } Which two code fragments can be independent...
- Question #164
Given the code fragments: interface Exportable { void export(); } class Tool implements Exportable { public void export() { System.out.println("Tool::export"); } } class ReportTool...
- Question #165
Given: interface Downloadable { public void download(); } interface Readable extends Downloadable { public void readbook(); } abstract class Book implements Readable { public void...
- Question #166
Given: class Student { String name; public Student(String name) { this.name = name; } public static void main(String[] args) { Student[] students = new Student[3]; students[1] = ne...
- Question #167
Given the code fragment: public static void main(String[] args) { ArrayList myList = new ArrayList(); String[] myArray = new String[5]; try { while (true) { myList.add("My String")...
- Question #168
Which three statements describe the object-oriented features of the Java language?
- Question #169
Given: public class Test { public static void main(String[] args) { boolean x = new Boolean(args[0]); boolean b = new Boolean(args[1]); System.out.println(x + " " + b); } } And giv...
- Question #170
Given: class Test { public static void main(String[] args) { int numbers[] = new int[4]; numbers[0] = 10; numbers[1] = 20; numbers = new int[4]; numbers[2] = 30; numbers[3] = 40; f...
- Question #171
Given the code snippet from a compiled Java source file: public class MyFile { public static void main(String[] args) { String arg1 = args[1]; String arg2 = args[2]; String arg3 =...
- Question #172
Which three advantages of the Java exception mechanism?
- Question #173
Given the code fragment: 24. float var1 = (12_345.01 >= 123_45.00) ? 12_456 : 124_56.02f; 25. float var2 = var1 * 1.024; 26. System.out.print(var2); What is the result?
- Question #174
public class Triangle { static double area; int b = 2, h = 3; public static void main(String[] args) { //line n1 if (area == 0) { b = 3; h = 4; P = 0.5; } //line n2 area = P * b *...
- Question #175
Which two class definitions fail to compile? (A) final class A1 { public A1() { } } (B) public class A2 { private static int I; private A2() { } } (C) final abstract class A5 { pro...
- Question #176
Given: public class Test { public static final int MIN = 1; public static void main(String[] args) { int x = 0; //line n1 if (checkLimit(x)) { System.out.println("Java SE"); } else...
- Question #177
Given: public class Myclass { public static void main(String[] args) { String s = " Java Duke "; int len = s.trim().length(); System.out.print(len); } } What is the result?
- Question #178
Given the following array: int[] intArr = {8, 16, 32, 64, 128}; Which two code fragments, independently, print each element in this array? A) for (int i : intArr) { System.out.prin...
- Question #179
Given the code fragment: int wd = 0; string days[] = {"sun", "mon", "wed", "sat"}; switch (days[wd]) { case "sun": wd = 1; break; case "mon": wd = 2; break; case "wed": wd = 2; bre...
- Question #180
Given the code fragment: public static void main(String[] args) { double discount = 0; int qty = Integer.parseInt(args[0]); //line n1 } And given the requirements: * If the value o...
- Question #181
Given the code fragment: int n[][] = {{1, 3}, {2, 4}}; for (int i = 0; i<n.length; i--) { for (int y : n[i]) { System.out.print(y); } } What is the result?
- Question #182
Given the code fragment: public static void main(String[] args) { String ta = "A"; ta.concat("B"); String tb = "C"; ta.concat(tb); ta.replace('C', 'D'); ta.concat(tb); System.out.p...
- Question #183
Given the code fragment: public class Person { String name; int age = 25; public Person(String name) { this(); //line n1 setName(name); } public Person(String name, int age) { Pers...
- Question #184
Given the code fragment: String shirts[][] = new String[2][2]; shirts[0][0] = "red"; shirts[0][1] = "blue"; shirts[1][0] = "small"; shirts[1][1] = "medium"; Which code fragment pri...
- Question #185
Given the code fragment: Path path1 = Paths.get("/software/././sys/readme.txt"); Path path2 = path1.normalize(); Path path3 = path2.relativize(path1); System.out.print(": " + path1...
- Question #186
Given: public class Product { String name; int qty; public String toString() { return name; } public Product(String name, int qty) { this.name = name; this.qty = qty; } static clas...
- Question #187
Given the content: MessagesBundle.properties file: username = Enter User Name password = Enter Password MessagesBundle_fr_FR.properties file: username = Entrez le nom d'utilisateur...
- Question #188
public class Foo { public void methodB(String s) { System.out.println("Foo " + s); } } public class Bar extends Foo { public void methodB(String s) { System.out.println("Bar " + s)...
- Question #189
Given the content of the employee.txt file: Every worker is a master. Given that the employee.txt file is accessible and the file allEmp.txt does NOT exist, and the code fragment:...
- Question #190
public class Job { String name; Integer cost; Job(String name, Integer cost) { this.name = name; this.cost = cost; } String getName() { return name; } int getCost() { return cost;...
- Question #191
Given the code fragment: List<String> l1 = Arrays.asList("Java", "J2EE", "J2ME", "JSTL", "JSP", "Oracle DB"); Predicate<String> pred = s -> s.contains("J2"); List<String> netL = l1...
- Question #192
Given: class Product { String pname; public Product(String pname) { this.pname = pname; } } and the code fragment: Product p1 = new Product("PowerCharger"); Product p2 = p1; System...
- Question #193
Given: class DataConverter { public void copyFlatFilesToTables() { } public void close() throws Exception { // line n1 throw new RuntimeException(); } } and the code fragment: publ...
- Question #194
Given the code fragment: try { Properties prop = new Properties(); prop.put("user", userName); prop.put("password", passWord); Connection conn = DriverManager.getConnection(dbURL,...
- Question #195
In 2015, daylight saving time in New York, USA, begins on March 8th at 2:00 AM. As a result, 2:00 AM becomes 3:00 AM. Given the code fragment: ZonedId zone = ZoneId.of("America/New...
- Question #196
Given the code fragment: for (Course a : Course.values()) { System.out.print(a + " Fees " + a.getCost() + " "); } Which is the valid definition of the Course enum?
- Question #197
Given: class Resource implements AutoCloseable { public void close() throws Exception { System.out.print("Close-"); } public void open() { System.out.print("Open-"); } } and this c...
- Question #198
Given the code fragment: List<String> cs = Arrays.asList("Java", "Java EE", "Java ME"); // line n1 System.out.print(b); Which code fragment, when inserted at line n1, ensures false...
- Question #199
Given the code fragment: final String str1 = "Java"; StringBuffer strBuf = new StringBuffer("Course"); UnaryOperator<String> s = (str2) -> str1.concat(str2); // line n1 UnaryOperat...
- Question #200
Given: class Engine { double fuelLevel; Engine(int fuelLevel) { this.fuelLevel = fuelLevel; } public void start() { // line n1 System.out.println("Started"); } public void stop() {...