1Z0-819 Exam Questions
200 real 1Z0-819 exam questions with expert-verified answers and explanations. Page 4 of 4.
- Question #151
Given the code fragment: public static void main(String[] args) { var even = List.of(1, even.add(-1); even.add(0, -2); even.add(0, -2); System.out.println(even); } What is the outp...
- Question #152
Which command line runs the main class com.acme.Main from the module com.example?
- Question #153
Given: import java.util.*; public class Main { static Map<String, String> map = new HashMap<>(); static List<String> keys = new ArrayList<>(List.of("A", "B", "C", "D")); static Str...
- Question #154
Given: public class Test { private int sum; public int compute() { int x = 0; while(x < 3) { sum += x++; } return sum; } public static void main(String[] args) { Test t = new Test(...
- Question #155
Given: public class X { private Collection collection; public void set (Collection collection) { this.collection = collection; } } and public class Y extends X { public void set (M...
- Question #156
Given: package a; public abstract class Animal { protected abstract void walk(); } package b; public abstract class Human extends Animal { // line 1 } Which two lines inserted in l...
- Question #157
Given: public class Tester { public static void main(String[] args) { int x = 4; int y = 2; System.out.println("x+y=" + (x+y)); } } What is the result?
- Question #158
public class Tester { public static void main(String[] args) { byte x = 7, y = 6; // Line 1 System.out.println(z); } } Which expression when added at Line 1 will produce the output...
- Question #159
public class Main { public static public static void main(String[] args) { int i = 1; for(String s : args) { System.out.println((i++) + " " + s); } } } executed with this command:...
- Question #160
Which of these initialization statements are correct? (Choose three.)
- Question #161
import java.io.FileNotFoundException; import java.io.IOException; public class Tester { public static void main(String[] args) { doA(); //Line 1 } private static void doA() throws...
- Question #162
What is the result of compiling and running the following code? public class Overload { static void print(int..., a2) { System.out.print("int...."); } static void print(long a, lon...
- Question #163
public class Test { private String strings; } Which two construct ors will compile and set the class field strings? (Choose two.)
- Question #164
Given the following fragment: String s1 = new String("ORACLE"); String s2 = "ORACLE"; String s3 = s1.intern(); System.out.println(s1 == s2 + " "); System.out.println(s1 == s3 + " "...
- Question #165
import java.util.function.BiFunction; public class Pair<T, Boolean> { final BiFunction<T, Boolean, T> validator; T left = null; T right = null; private Pair() { validator = null; }...
- Question #166
var i = 10; var j = 5; var z = (++i + j++) / i - 2; System.out.println(i); What is the result?
- Question #167
public class Tester { private int x; private int y; public static void main(String[] args) { Tester t1 = new Tester(); t1.x = 2; t1.y = 3; Tester t2 = new Tester(); t2.x = 4; t2.y...
- Question #168
public interface EulerInterface { double getEulerValue(); } public class EulerLambda { public static void main(String[] args) { EulerInterface myEulerInterface = () -> 2.71828; Sys...
- Question #169
public class Myclass { public static void main(String[] args) { System.out.println(arg[1] + "--" + arg[3] + "--" + arg[0]); } } executed using this command: java Myclass My Car Is...
- Question #170
Which describes a characteristic of setting up the Java development environment?
- Question #171
Given: ```java package test.t1; public class A { public int x = 42; protected A() { } } package test.t2; import test.t1.*; public class B extends A { int x = 17; public B() { super...
- Question #172
Given: ```java String s = "this is it"; int x = s.indexOf("is"); s = s.substring(x+3); x = s.indexOf("is"); System.out.println(s+" "+x); ``` What is the result?
- Question #173
Given: ```java import java.util.ArrayList; import java.util.Arrays; public class TestMe { public static void main(String[] args) { String[] fruitNames = {"apple", "orange", "grape"...
- Question #174
Given the code fragment: ```java int x = 0; while(x < 10) { System.out.print(x++); } ``` Which "for" loop produces the same output?
- Question #175
Which of the following produces the same result as the given for loop? ```java for (int i = 1; i < 10; ++i) { System.out.println(i); } ```
- Question #176
Given: ```java String[][] arr = { {"Red", "White"}, {"Black"}, {"Blue", "Yellow", "Green", "Violet"} }; for(int row = 0; row < arr.length; row++) { int column = 0; for(; column < a...
- Question #177
Given: public class Main { public static void main(String[] args) { import java.time.LocalDate; import static java.time.DayOfWeek.*; var today = LocalDate.now().with(TUESDAY).getDa...
- Question #178
Given: public interface A { abstract void x(); } and public abstract class B /* position 1 */ { /* position 2 */ public void x() { } public abstract void z(); } and public class C...
- Question #179
Given: import java.util.function.Supplier; public class MyLambda { public static void main(String[] args) { int i = 25; Supplier<Integer> foo = () -> i; i++; System.out.println(foo...
- Question #180
Which two statements are correct about modules in Java? (Choose two.)
- Question #181
Which two describe reasons to modularize the JDK? (Choose two.)
- Question #182
Given: public class Employee { private String name; private String neighborhood; private LocalDate birthday; private int salary; // ...getters and setters } and List<Employee> rost...
- Question #183
Given TripleThis.java: 1 import java.util.function.*; 2 3 public class TripleThis { 4 public static void main(String[] args) { 5 Function<Integer, Integer> tripler = x -> { return...
- Question #184
Given config: MessageBundle.properties: username = Username password = Password and MessageBundle_fr_FR.properties: username = Utilisateur password = le passe and MessageBundle_ru....
- Question #185
Given: public class Main { public static void main(String[] args) { List<String> list1 = new ArrayList<>(); list1.add("Plane"); list1.add("Automobile"); list1.add("Motorcycle"); Li...
- Question #186
Given the code fragment: public class Test { private int x = 1; static final int y; public Test(){ System.out.println(x); System.out.println(y); } { x = 2; } static { y = 3; } publ...
- Question #187
What change will cause the code to compile successfully? Given: public class Electronics { public Electronics(double price) { super(); } } and public class Plushy extends Electroni...
- Question #188
Given: import java.io.File; import java.io.FileOutputStream; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.util.Arrays; public class Test { public s...
- Question #189
```java public class X { protected void print(Object obj) { print(objects); } public final void print(Object... objects) { collection.forEach(System.out::println); } } public class...
- Question #190
Which method throws an exception for not-a-number and infinite input values?```java // A static float validate1(String s, float min, float max) throws IllegalArgumentException { re...
- Question #191
Given the `CopyServiceAPI` that has the org.copyservice.spi. Copy Interface To use this service in a module, which module- info java would be correct?
- Question #192
Given: `List<Integer> numbers = List.of(5, 3, 0, 8, 1, 9, 5, 7, 6, 4); int sum = numbers.stream().reduce(0, (n, m) -> n + m); // line 1` You want to make the reduction operation pa...
- Question #193
Given: ```java public class Tester { public static void main(String[] args) { String s = "Hat at store"; String t = new String("Hat"); s.substring(s.indexOf(' ') + 1); s.concat(" a...
- Question #194
Given: ```java public class GameObject { public GameObject() {} public GameObject(int x, int y) { System.out.println("move(" + x + "," + y + ")"); } public Integer move(Integer x,...
- Question #195
Given the code fragment: ```java for (i=0; i<10; i++) { System.out.print(i + " "); } ``` What is the result?
- Question #196
A company has an existing Java app that includes two Java 8 jar files, sales-3.10.jar and clients- 10.2.jar. The sales-3.10.jar uses packages in clients-10.2.jar, but clients-10.2....
- Question #197
How many Thing objects are eligible for garbage collection in line 1? ```java private String name; public Thing(String name) { this.name = name; } public String toString() { return...
- Question #198
Given the Customer table structure: `ID Number Primary Key NAME Varchar(20)` Given code fragment: `12. PreparedStatement stmt = con.prepareStatement("INSERT INTO CUSTOMER VALUES (?...
- Question #199
You want to implement the jav `MyPersistenceData` class so that it can be serialized and deserialized into a file. Which interface and methods would you implement?```java public cl...
- Question #200
Given: ```java public class ConSuper { public ConSuper() { this(2); } protected ConSuper(int a) { System.out.print("3"); } public ConSuper(int a) { System.out.print(a); } } public...