1Z0-819 Exam Questions
200 real 1Z0-819 exam questions with expert-verified answers and explanations. Page 3 of 4.
- Question #101
Which two safely validate inputs? (Choose two.)
- Question #102
Consider the method declaration: public void setSessionUser(Connection conn, String user) throws SQLException { Statement stmt = conn.createStatement(); String sql = "<EXPRESSION>"...
- Question #103
Which three annotation uses are valid? (Choose three.)
- Question #104
Which two statements correctly describe capabilities of interfaces and abstract classes? (Choose two.)
- Question #105
Given: public static void main(String[] args) { final List<String> fruits = List.of("Orange", "Apple", "Lemon", "Raspberry"); final List<String> types = List.of("Juice", "Pie", "Ic...
- Question #106
Which interface in the java.util.function package can return a primitive type?
- Question #107
Given: enum QUALITY { A(100), B(75), C(50); int percent; private QUALITY(int percent) { this.percent = percent; } } and checkQuality(QUALITY A); and void checkQuality(QUALITY q) {...
- Question #108
Given: LocalDate dl = LocalDate.of(1997, 2, 7); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("/*Insert code here*/"); System.out.println(dtf.format(dl)); Which pattern forma...
- Question #109
Which two statements inherently compile? (Choose two.)
- Question #110
Given this enum declaration: 1. enum Letter { 2. A(ALPHA(300), BETA(200), GAMMA(300)); 3. int v; 4. 5. Letter(int v) { this.v = v; } 6. /* Insert code here */ 7. } Examine this cod...
- Question #111
Given the fragment: Path source = Paths.get("/repo/a.txt"); Path destination = Paths.get("/repo/"); // line 1 Files.delete(destination); // line 2 Files.delete(source); // line 3 A...
- Question #112
Given: List<String> longlist = List.of("Hello", "World", "Best"); List<String> shortlist = new ArrayList<>(); Which code fragment correctly forms a short list of words containing t...
- Question #113
jdeps -jdkinternals C:\workspace4\SimpleSecurity\jar\classes.jar Which describes the expected output?
- Question #114
Given: public class Main { public static void main(String[] args) { List<String> arrayList = new ArrayList<>(); arrayList.add("hello"); arrayList.add("world"); print(1); } private...
- Question #115
Which two are functional interfaces? (Choose two.)
- Question #116
Given: // line 1 List<String> fruits = new ArrayList<>(List.of("apple", "orange", "banana"))); fruits.replaceAll(function); Which statement on line 1 enables this code fragment to...
- Question #117
What will be the output of this code? var i = 1234; if (i == "1234") { System.out.println("Alpha"); } else if (i == 1234) { System.out.println("Beta"); } else { System.out.println(...
- Question #118
Given: public static void print(int[] nums) { // Add code here } Which of the following code fragments can be inserted within the print() method, so that all the numbers from 1 to...
- Question #119
Which of the following statements are true about the finally block?
- Question #120
Given: public class A { private boolean checkValue(int val) { return true; } } and public class B extends A { public int modifyVal(int val) { if (checkValue(val)) { return val; } e...
- Question #121
Given: public interface API { //line 1 public void checkValue(Object value) throws IllegalArgumentException; //line 2 public boolean isValidNumber(Object val) { if (val instanceof...
- Question #122
Which two modules include APIs in the Java SE Specification? (Choose two.)
- Question #123
Given: public class Test{ private int num = 1; private int div = 0; public void divide() { try { num = num / div; System.out.print("Exception"); } catch (ArithmeticException ae) {...
- Question #124
Which two statements are true about the modular JDK? (Choose two.)
- Question #125
Given the code fragment: int[] secA = { 1, 2, 4, 6, 8, 10 }; int[] secB = { 1, 2, 4, 6, 8, 10 }; int res1 = Arrays.mismatch(secA, secB); int res2 = Arrays.compare(secA, secB); Syst...
- Question #126
Given: import java.io.*; public class Tester { public static void main(String[] args) { try { doA(); } catch(IOException e) { System.out.print("c"); } finally{ System.out.print("d"...
- Question #127
Which of the following commands is necessary to create and run a custom runtime image from Java source files?
- Question #128
Given public class Tester { public static void main(String[] args) { StringBuilder sb = new StringBuilder(5); sb.append("HOWDY"); sb.insert(1, "LL"); sb.replace(3, 5, "COW"); sb.de...
- Question #129
Which of the following pairs of methods satisfy overloading rules?
- Question #130
Which of the following options can be added to line 4 for the code to compile correctly? Given: var list = new ArrayList<String>(); list.add("one"); list.add("two"); //line 4 for (...
- Question #131
Which of the following are advantages of Java Platform Module System?
- Question #132
Given: package p1; public class Person { protected Person() { } //line 1 } and package a; import b.Person; public class Main { //line 2 public static void main(String[] args) { Per...
- Question #133
Given: 1. Iterator iter = List.of(1,2,3).iterator(); 2. while (iter.hasNext()) { 3. foo(iter.next()); 4. } 5. Iterator iter2 = List.of(1,2,3).iterator(); 6. while (iter.hasNext())...
- Question #134
Which two statements are true about Java modules? (Choose two.)
- Question #135
Given: class Mycar { } and javac C:\workspace4\Mycar.java What is the expected result of javac?
- Question #136
Given: 1. interface Pastry { 2. void getIngredients(); 3. } 4. abstract class Cookie implements Pastry {} 5. 6. class chocolateCookie implements Cookie { 7. public void getIngredie...
- Question #137
Given: StringBuilder s = new StringBuilder("ABCD"); Which would cause s to be ACDQ?
- Question #138
Given: class Employee { String office; } and the code fragment: 5. public class HRapp { 6. var employees = new ArrayList<Employee>(); 7. public void display() { 8. var employee = n...
- Question #139
Given: Path p = Path.of("mango"); // line 1 Path p1 = p.resolve("guava"); // line 2 Path p2 = p.resolve("guava"); // line 3 Path p3 = p2.resolve("../", "apple"); // line 4 System.o...
- Question #140
Given: var sql = "SELECT * FROM students"; try (var conn = DriverManager.getConnection(args[0]); var ps = conn.prepareStatement(sql)) { ResultSet rs = ps._ ____(); while (rs.next()...
- Question #141
Which of the following are true about annotations?
- Question #142
Given: public interface InterfaceOne { void printOne(); } Which three classes successfully override printOne()? (Choose three.)
- Question #143
Given: public class Test { public static void main(String[] args) { AnotherClass ac = new AnotherClass(); SomeClass sc = new AnotherClass(); ac = sc; sc.methodA(); ac.methodA(); }...
- Question #144
Which two statements are correct about try blocks? (Choose two.)
- Question #145
Given: public class Over { public void analyze(Object o) { System.out.println("I am an object array"); } public void analyze(long[] l) { System.out.println("I am an array"); } publ...
- Question #146
Given: public class Price { private final double value; public Price(String value) { this(Double.parseDouble(value)); } public Price(double value) { this.value = value; } public Pr...
- Question #147
Given: class ConSuper { protected ConSuper() { this(2); } System.out.print("1"); } protected ConSuper(int a) { System.out.print(a); } } and public class ConSub extends ConSuper{ Co...
- Question #148
What is the result of running this code if these three property files are available. employees.properties --------------------- name=Nick age=44 salary=10000 employees_CA.propertie...
- Question #149
Which of the following lines in this code do not compile? (Choose all that apply.) enum WeatherType { COLD, WARM; } @Documented @interface Weather { // Line 1 String humidity(); //...
- Question #150
Which statement about access modifiers is correct?