1Z0-819 Exam Questions
200 real 1Z0-819 exam questions with expert-verified answers and explanations. Page 2 of 4.
- Question #51
Given var fruits = List.of("apple", "orange", "banana", "lemon"); You want to examine the first element that contains the character 'n'. Which statement will accomplish this?
- Question #52
Given public class Foo { private final ReentrantLock lock = new ReentrantLock(); private State state; public void foo() throws Exception { try { lock.lock(); state.mutate(); } fina...
- Question #53
Given var data = new ArrayList<>(); data.add(10*10); data.add(30); data.add("Market Road"); data.add(1, 2, 3); data.remove(2); data.remove(null); system.out.print(data); What is th...
- Question #54
Which code fragment compiles?
- Question #55
Which two are successful examples of autoboxing? (Choose two.)
- Question #56
Given public class Hello { class Greeting { void sayHi() { System.out.println("Hello world"); } } public static void main(String[] args) { // Line 1 } } What code must you insert o...
- Question #57
Which code fragment prints 100 random numbers?
- Question #58
You are working on a functional bug in a tool used by your development organization. In your investigation, you find that the tool is executed with a security policy file containin...
- Question #59
Given an application with a main module that has this module-info.java file: module main { exports country; uses country.CountryDetails; } Which two are true? (Choose two.)
- Question #60
Given public enum Color implements Serializable { R(1), G(2), B(3); int c; public Color(int c) { this.c = c; } } What action ensures successful compilation?
- Question #61
You want to calculate the average of numbers. numbers = List.of(1,2,3,4,5,6,7,8,9); Which two codes will accomplish this? (Choose two.)
- Question #62
Given try { // line 1 lines.map(l -> l.toUpperCase()) .forEach (line -> { try { Files.write(Paths.get("outputfile_to_path"), line.getBytes(),StandardOpenOption.CREATE); } catch (IO...
- Question #63
public class Main { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String input = br.readLine(); System.o...
- Question #64
Given public class Employee { private String name; private LocalDate birthday; // the constructors, getters, and setters methods go here } and List<Employee> roster = new ArrayList...
- Question #65
Given import java.util.List; import java.util.function.BinaryOperator; public class Main { public static void main(String... args) { List<Employee> list = List.of(new Employee("Joh...
- Question #66
What type of value in the java.util.function package will return a void return type?
- Question #67
Given public class MyResource { public MyResource () { // Resource methods } } You want to use the MyResource class in a try-with-resources statement. Which change will accomplish...
- Question #68
@Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface AuthorInfo { String author() default ""; String date(); String[] comments() default {}; } Which tw...
- Question #69
Given public class Main { public static void main (String[] args) { Path path = Paths.get("/u01/work/filestore.txt"); boolean test = Files.deleteIfExists(path); if (test) System.ou...
- Question #70
public class Tester { public static class Person implements /* line 1 */ { private String name; Person(String name) { this.name = name; } /* line 2 */ } public static void main(Str...
- Question #71
Class CustomType<T> { int count (T[] anArray, T element) { int count = 0; for (T x : anArray) { if (e.equals(element)) ++count; } return count; } } and public class Test extends Cu...
- Question #72
Which statement about a functional interface is true?
- Question #73
Given public class Main { public static void main (String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { System.out.print("Input: "); St...
- Question #74
Given public class X { } and public final class Y extends X { } What is the result of compiling these two classes?
- Question #75
First Final Round? Which code is correct? A. Runnable r = () -> Message".-> System.out.println(); B. Runnable r = () -> System.out::print; C. Runnable r = () -> (System.out.println...
- Question #76
Given: public class FunctionalInterfaceTest { public static void main(String[] args) { List<String> fruits = Arrays.asList("apple", "orange", "banana"); Consumer<String> c = System...
- Question #77
Given: public class Test { public static void doThings() throws GeneralException { try { throw new RuntimeException("Something happened"); } catch (Exception e) { throw new Specifi...
- Question #78
Given: List<Reader> dataFiles = new ArrayList<>(); dataFiles.add(new FileReader("MyIndex.idx")); File indexReaderFile = new FileReader(indexFile); try (BufferedReader indexReader =...
- Question #79
A company has an existing sales application using a Java 8 jar file containing packages: com.company.customer; com.company.customer.orders; com.company.customer.sales; com.company....
- Question #80
Given: String originalPath = "data\\projects\\a-project\\..\\..\\another-project"; Path path = Paths.get(originalPath); System.out.print(path.normalize()); What is the result?
- Question #81
Given: public class Main { public static void main(String[] args) { Consumer<String> msg -> System.out::print; // line 1 Consumer.accept("Hello Lambda !"); } } This code results in...
- Question #82
Given int arr[][] = {{5,10},{8,12},{9,3}}; long count = Stream.of(arr) .flatMapToInt(IntStream::of) .map(n -> n + 1) .filter(n -> (n % 2 == 0)) .peek(System.out::print) .count(); S...
- Question #83
Which is a proper JDBC URL?
- Question #84
Given: public class SerializedMessage implements Serializable { String message; LocalDateTime createdTime; transient LocalDateTime updatedDateTime; SerializedMessage(String message...
- Question #85
Given: 1. void insertionSort (int values[]) { 2. int n = values.length; 3. for (int i = 1; i < n; i++) { 4. int tmp = values[i]; 5. int j = i - 1; 6. while (j >= 0 && (values[j] >...
- Question #86
Given: List<String> list1 = new ArrayList<>(); list1.add("A"); list1.add("B"); list1.add("C"); List<String> list2 = List.of(list1, list2); List<String> list3 = list.of(list1); Syst...
- Question #87
Given: 1. public class Secret { 2. String[] names; 3. public Secret(String[] names) { 4. this.names = names; 5. } 6. public String[] getNames() { 7. return names; 8. } 9. } Which t...
- Question #88
Given: Integer[] intArray = {2, 1, 3, 4, 5}; List<Integer> list = new ArrayList<>(Arrays.asList(intArray)); list.parallelStream() .forEach(e -> System.out.print(e + " ")); Which ar...
- Question #89
Given the contents: MessageBundle_en.properties file: message=Hello MessageBundle_en.properties file: message=Hello there MessageBundle_US.properties file: message=Howdy MessageBun...
- Question #90
Given: public class Main { public static void main(String[] args) { var numbers = List.of(1,2,3,4,5,6,7,8,9,10); OptionalInt integer = numbers.stream().filter(x -> x % 3 != 0).redu...
- Question #91
Given: List<String> hsl = new LinkedList<String>(); Set<String> hs1 = new HashSet<String>(); String[] s = {"a", "b", "c", "b", "a"}; for (String st : s) list1.add(st); hs1.add(st);...
- Question #92
public class Main { class Student { String classname; Student(String classname) { this.classname = classname; } } public static void main(String[] args) { Student student = new Stu...
- Question #93
Given: public class Employee { private String name; private String locality; /* the constructor, getter and setter methods code goes here */ } and: List<Employee> roster = new Arra...
- Question #94
Given the Person class with age and name along with getter and setter methods, and this code fragment: List<Person> persons = new ArrayList(List.of(new Person(44, "Tom"), new Perso...
- Question #95
Which three guidelines are used to protect confidential information? (Choose three.)
- Question #96
Given: public static void main(String[] args) { try { Reader reader1 = new FileReader("File1.txt"); Reader reader2 = new FileReader("File2.txt"); Reader reader3 = new FileReader("F...
- Question #97
Given the code fragment: var pool = Executors.newFixedThreadPool(5); Future<Integer> result = pool.submit(() -> 1); Which type of lambda expression is passed into submit()?
- Question #98
Which two statements set the default locale used for formatting numbers, currency, and percentages? (Choose two.)
- Question #99
Given: public class Confidential implements Serializable{ private String data; public Confidential(String data) { this.data = data; } } Which two are secure serialization of these...
- Question #100
A bookstore's sales are represented by a list of Sale objects populated with the name of the customer and the books they purchased. public class Sale { String customer; private Lis...