1Z0-809 Exam Questions
277 real 1Z0-809 exam questions with expert-verified answers and explanations. Page 2 of 6.
- Question #51
Given: class Worker extends Thread { CyclicBarrier cb; public Worker (CyclicBarrier cb) { this.cb = cb; } public void run () { try { cb.await(); System.out.println ("Worker..."); }...
- Question #52
Given: class Alpha { int ns; static int S; Alpha (int ns) { if (S < ns) { S = ns; this.ns = ns; } } void doPrint() { System.out.println ("ns = " + ns + " S = " + S); } } And, publi...
- Question #53
unSortMap.put (7, "e"); unSortMap.put (50, "m"); Map<Integer, String> treeMap = new TreeMap <Integer, String> (new Comparator<Integer> () { @Override public int compare (Integer o1...
- Question #54
Given the code fragments: class Employee { Optional<Address> address; Employee (Optional<Address> address) { this.address = address; } public Optional<Address> getAddress() { retur...
- Question #55
Given the code fragment: String color = "teal"; switch (color) { case "Red": System.out.println("Found Red"); case "Blue": System.out.println("Found Blue"); break; case "Teal": Sys...
- Question #56
public class Test { public static void dispResult(int [] num) { try { System.out.println (num [1] / (num[1] - num[2])); } catch (ArithmeticException e) { System.err.println("first...
- Question #57
Given: public class Msg { public static String doMsg(char x) { return "Good Day!"; } public static String doMsg(int y) { return "Good Luck!"; } public static void main(String[] arg...
- Question #58
Given the code fragment: List<String> listVal = Arrays.asList("Joe", "Paul", "Alice", "Tom"); System.out.println ( // line n1 ); Which code fragment, when inserted at line n1, enab...
- Question #59
Which statement is true about java.util.Stream?
- Question #60
Given the code fragment: String str = "Java is a programming language"; ToIntFunction<String> indexVal = str :: indexOf; //line n1 int x = indexVal.applyAsInt("Java"); //line n2 Sy...
- Question #61
Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked. What is the result?
- Question #62
Given the following abstract class Shape: ```java public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { thi...
- Question #63
Given the following code: ```java public enum USCurrency { PENNY (1), NICKLE (5), DIME (10), QUARTER (25); int value; private USCurrency (int value) { this.value = value; } } publi...
- Question #64
Given the following code and code fragment: ```java class Sum extends RecursiveAction { //line n1 static final int THRESHOLD_SIZE = 3; int stIndex, lsIndex; int [] data; public Sum...
- Question #65
Given the code format: ```java class DBConfiguration { String user; String password; } ``` And the following partial class definition for `DBHandler`: ```java public class DBHandle...
- Question #66
Given the code fragment: ```java List<String> nl = Arrays.asList("Jim", "John", "Jeff"); Function<String, String> funVal = s -> "Hello : ".concat(s); nl.stream() .map(funVal) .forE...
- Question #67
Given the code fragment: ```java Path path1 = Paths.get("/app/../sys/"); Path res1 = path1.resolve("log"); Path path2 = Paths.get("/server/exe/"); Path res2 = path2.resolve("../rea...
- Question #68
Which two statements are true for a two-dimensional array of primitive data type?
- Question #69
View the exhibit. Given the code fragment: Which change enables the code fragment to print the following in the event of missing info or age out of range? James age: 20 Williams ag...
- Question #70
Given: What is the result?
- Question #71
Given: Which modification enables the code fragment to print Happy Journey!?
- Question #72
Given the code fragment: What is the result?
- Question #73
Given the code fragments: What is the result?
- Question #74
Path source = Paths.get("/data/december/log.txt"); Path destination = Paths.get("/data"); Files.copy(source, destination); What is the result?
- Question #75
The protected modifier on a Field declaration within a public class means that the field ____________.
- Question #76
Given: public class Case { public static void main(String[] args) { String product = "Pen"; product.toLowerCase(); product.concat(" " + product.toLowerCase()); System.out.print(pro...
- Question #77
Given: class CheckClass { public static int checkValue (String s1, String s2) { return s1.length() ?s2.length(); } } and the code fragment: String[] strArray = new String [] {"Tige...
- Question #78
Given the code fragment: Map<Integer, String> books = new TreeMap<>(); books.put (1007, "A"); books.put (1001, "B"); books.put (1001, "B"); books.put (1003, "B"); System.out.printl...
- Question #79
Given the code fragment: public class ForTest { public static void main(String[] args) { int[] arrar = {1,2,3}; for ( foo ) { } } } Which three are valid replacements for foo so th...
- Question #80
Given the definition of the Vehicle class: class Vehicle { int distance;//line n1 Vehicle (int x) { this.distance = x; } } public void increSpeed(int time) {//line n2 int timeTrave...
- Question #81
Given: public class X { public static void main(String[] args) { String theString = "Hello World"; System.out.println(theString.charAt(11)); } } What is the result?
- Question #82
Given: class Test { int sum = 0; public void doCheck(int number) { if (number % 2 == 0) { break; } else { for (int i = 0; i < number; i++) { sum += i; } } } public static void main...
- Question #83
Given the code fragments: interface CourseFilter extends Predicate<String> { public default boolean test (String str) { return str.equals ("Java"); } } and List<String> strs = Arra...
- Question #84
return output; } and the code fragment: Book b1 = new Book (101, "Java Programming"); Book b2 = new Book (102, "Java Programming"); System.out.println (b1.equals(b2)); //line n2 Wh...
- Question #85
The data doc, data.txt and data.xml files are accessible and contain text. Given the code fragment: Stream<Path> paths = Stream.of (Paths.get ("data.doc"), Paths.get ("data.txt"),...
- Question #86
Given the code fragment: Arrays.asList ("1", "John"), Arrays.asList ("2", null)); Stream<String> jInst = iStr.flatMapToTnt ((x -> x.stream ())); jInst.forEach (System.out :: print)...
- Question #87
Given the code fragment: Stream<Path> files = Files.walk(Paths.get(System.getProperty("user.home"))); files.forEach (fName -> { //line n1 try { Path aPath = fName.toAbsolutePath();...
- Question #88
Given the code fragment: 9. Connection conn = DriverManager.getConnection (dbURL, userName, password); 10. String query = "SELECT id FROM Employee"; 11. try (Statement stmt = conn....
- Question #89
Given the code fragment: List<String> nl = Arrays.asList ("Jim", "John", "Jeff"); Function<String, String> funVal = s -> "Hello : ".concat(s); nL.stream() .map (funVal) .peek (Syst...
- Question #90
Given: public class SampleClass { public static void main(String[] args) { AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass(); sc = asc; System.o...
- Question #91
Given the code fragment: Path p1 = Paths.get("/Pics/MyPic.jpeg"); System.out.println (p1.getNameCount() + ":" + p1.getName(1) + ":" + p1.getFileName()); Assume that the Pics direct...
- Question #92
Given: class Vehicle implements Comparable<Vehicle>{ int vno; String name; public Vehicle (int vno, String name) { this.vno = vno; this.name = name; } public String toString () { r...
- Question #93
Given: public class App { public static void main (String[] args) { int i = 10; int j = 20; int k = j + i / 5; System.out.print (i + " : " + j + " : " + k); } } What is the result?
- Question #94
switch (accountType) { case "RD": rateOfInterest = 5; break; case "FD": rateOfInterest = 10; break; default: assert false: "No interest for this account"; //line n1 } System.out.pr...
- Question #95
Given: public class Test3 { public static void main(String[] args) { String names[] = new String[3]; names[0] = "Marry Brown"; names[1] = "Nancy Red"; names[2] = "Jessy Orange"; fo...
- Question #96
Given: public class MyFor1 { public static void main(String[] args) { int[] x = {6, 7, 8}; for (int i : x) { System.out.print(i + " "); i++; } } } What is the result?
- Question #97
Given the code fragment: UnaryOperator<Double> uol = s -> s*2; //line n1 List<Double> loanValues = Arrays.asList(1000.0, 2000.0); loanValues.stream() .filter(lv -> lv >= 1500) .map...
- Question #98
Given: ITEM ID, INTEGER: PK DESCRIP, VARCHAR (100) PRICE, REAL QUANTITY < INTEGER And given the code fragment: 9. try { 10. Connection conn = DriverManager.getConnection(dbURL, use...
- Question #99
Given the definition of the Country class: public class Country { public enum Continent {ASIA, EUROPE} String name; Continent region; public Country (String na, Continent reg) { na...
- Question #100
Given the code fragment class Test2 { int fvar; static int cvar; public static void main(String[] args) { Test2 t = new Test2(); // insert code here to write field variables } } Wh...