1Z0-819 Exam Questions
200 real 1Z0-819 exam questions with expert-verified answers and explanations. Page 1 of 4.
- Question #1
Given: public class Test { public static void main(String[] args) { int x; int y = 5; if (y > 2) { x = ++y; } else { y++; } System.out.print(x + " " + y); } } What is the result?
- Question #2
Given: public class DNASynth { int aCount; int tCount; int cCount; int gCount; void setACount(int cCount) { cCount = cCount; } void setTCount() { this.tCount = tCount; } int setCCo...
- Question #3
Given: public class Tester { public static void main(String[] args) { char letter = 'b'; int i = 0; switch (letter) { case 'a': i++; break; case 'b': i++; case 'c': // 'd': // line...
- Question #4
Given this code fragment: int x = 0; do { x++; if (x == 1) { continue; } System.out.println(x); } while (x < 1); What is the result?
- Question #5
Given: public class Foo { public static void main(String... args) { for (var x : args) { System.out.println(x); } } } What is the type of the local variable x?
- Question #6
Analyze the code: public class Test { private static String prefix = "Global:"; public static String name = "Namespace"; public static String getName() { return new Test().name; }...
- Question #7
Given: import java.util.*; public class Foo { public public List<Number> foo(Set<CharSequence> m) { ... } } and import java.util.*; public class Bar extends Foo { //line 1 } Which...
- Question #8
Given: public class Foo { private void print() { System.out.println("Bonjour le monde!"); } public void foo() { print(); } } public class Bar extends Foo { private void print() { S...
- Question #9
Given: public method foo() throws FooException { ... } and omitting the throws FooException clause results in a compilation error.Which statement is true about FooException?
- Question #10
Which describes an aspect of Java that contributes to high performance?
- Question #11
Which two method implementations are correct, when inserted independently in line 1? (Choose two.)
- Question #12
Given this formula to calculate a monthly mortgage payment: M = P * (i(1+i)^n) / ((1+i)^n - 1) and these declarations: double m; double i = 0.05/12; //monthly interest rate int p =...
- Question #13
Which is the correct order of possible statements in the structure of a Java class file?
- Question #14
Module vehicle depends on module part and makes its com.vehicle package available for all other modules. Which module-info.java declaration meets the requirement?
- Question #15
Given: ```java public interface ExampleInterface { } ``` Which two statements are valid to be written in this interface? (Choose two.)
- Question #16
Given: ```java public static void main(String[] args) { for (int i = 0; i < args.length; i++) { System.out.println(i + ": " + args[i]); switch (args[i]) { case "one": continue; cas...
- Question #17
Given: ```java public interface Builder { public A build(String str); } ``` and ```java public class BuilderImpl implements Builder { @Override public B build(String str) { return...
- Question #18
Given: ```java public class Sportscar extends Automobile { private float turbo; public void setTurbo (float turbo) { this.turbo = turbo; } } ``` What is known about the Sportscar c...
- Question #19
Given: ```java public interface A { a(); } public interface B extends A { b(); } public interface C extends A { public Path c(); } public interface D extends B, C { } ``` Why does...
- Question #20
Given: ```java package test; import java.time.*; public class Diary { private LocalDate now = LocalDate.now(); public LocalDate getDate() { return now; } } ``` and ```java package...
- Question #21
Given: ```java package A; class Test { String name; public Test (String name) { this.name = name; } public String toString() { return name; } } ``` and ```java package B; import A....
- Question #22
Given: ```java List<String> list = ...; list.forEach(x -> { System.out.println(x); }); ``` What is the type of x?
- Question #23
Given this code fragment: ```java String s = ""; if (Double.parseDouble("11.00F") > 11) { s += 1; } if (1 == Integer.valueOf("17")) { s += 2; } if (1024 > 1023L) { s += 3; } System...
- Question #24
Given: public class Foo { public void foo(Collection arg) { System.out.println("Bonjour le monde!"); } } and public class Bar extends Foo { public void foo(Collection arg) { System...
- Question #25
Given: public class Person { private String name = "Joe Bloggs"; public Person(String name) { this.name = name; } public String toString() { return name; } } and public class Teste...
- Question #26
Given: public class DMASynth { int aCount; int tCount; int cCount; int gCount; int getAcount(int xCount){ return aCount; } int getTcount(int tcount){ return this.tCount; } int getC...
- Question #27
Given: public class Main { public static void checkConfiguration(String filename) { File file = new File(filename); if(!file.exists()) { throw new Error("Fatal Error: Configuration...
- Question #28
Which statement is true about the Fox class?
- Question #29
Given: Automobile.java public abstract class Automobile { //line 1 abstract void wheels(); } Car.java public class Car extends Automobile { void wheels(int i) { // line 2 System.ou...
- Question #30
Given: /code/a/Test.java containing: package a; import b.Best; public class Test { public static void main(String[] args) { Best b = new Best(); } } and /code/b/Best.java containin...
- Question #31
Examine this excerpt from the declaration of the java.se module: module java.se { requires transitive java.sql; ... } What does the transitive modifier mean?
- Question #32
Given: public class Person { private String name; public Person(String name) { this.name = name; } public String toString() { return name; } } and public class Tester { public stat...
- Question #33
Given: class Super { static String greeting() { return "Good Night"; } String name() { return "Harry"; } } and class Sub extends Super { static String greeting() { return "Good Mor...
- Question #34
Given: 1. public class Main { 2. public static void greet(String... args) { 3. System.out.print("Hello "); 4. for (String arg : args) { 5. System.out.println(arg); 6. } 7. } 8. pub...
- Question #35
Given: for (var i = 0; i < 10; i++) { switch(i%5) { case 2: i+=3; break; case 1: i++; break; case 3: i++; continue; default: break; } System.out.print(i + " "); i++; } What is the...
- Question #36
What makes Java dynamic?
- Question #37
Given the code fragment: Path currentFile = Paths.get("/scratch/exam/temp.txt"); Path outputFile = Paths.get("/scratch/exam/new.txt"); Path directory = Paths.get("/scratch/"); File...
- Question #38
Given the declaration: @interface Resource { String name(); int priority() default 0; } Examine this code fragment: /* Loc1 */ /* class ProcessOrders { ... } Which two annotations...
- Question #39
Given interface MyInterface1 { public int method1() throws Exception; private void pMethod() { /* an implementation of pMethod */ } } interface MyInterface2 { public static void sM...
- Question #40
Given this enum declaration: 1. enum Alphabet { 2. A, B, C 3. } 4. Examine this code: System.out.println(Alphabet.getFirstLetter()); What line should be written at line 3 to make t...
- Question #41
Given the two classes: public class Resource { public Worker owner; public synchronized boolean claim(Worker worker) { if (owner == null) { owner = worker; return true; } else retu...
- Question #42
Given: public interface TestInterface { default public void samplingProbeProcedure() { probeProcedure(); System.out.println("Collect Sample"); System.out.println("Leave Asteroid");...
- Question #43
Given: public class Main { public static void main(String[] args) { Thread t1 = new Thread(new MyThread()); Thread t2 = new Thread(new MyThread()); Thread t3 = new Thread(new MyThr...
- Question #44
Which code fragment does a service use to load the service provider with a Print interface?
- Question #45
Examine these module declarations: module ServiceAPI { exports com.example.api; } module ServiceProvider { requires ServiceAPI; provides com.example.api with com.myimp1.imp1; } mod...
- Question #46
Given: public class Main { public static void main(String[] args) { String str = Value.orElse("Duke"); System.out.println(str); } static Optional<String> createValue() { String s =...
- Question #47
Given 1. public class Test { 2. private static class Greet { 3. private void print() { 4. System.out.println("Hello World"); 5. } 6. } 7. public static void main(String[] args) { 8...
- Question #48
Assume db is a DataSource and the EMP table is defined appropriately. try (Connection conn = ds.getConnection(); PreparedStatement ps = conn.prepareStatement("INSERT INTO EMP VALUE...
- Question #49
Assuming that Widget class has a getPrice method t is code does not compile: List widgets = List.of( new Widget("Basic Widget", 19.55), // line 1 new Widget("Enhanced Widget", 35.0...
- Question #50
Given var numbers = List.of(1,2,3,4,5,6,7,8,9,10); for(int a: numbers){ StringBuilder sb = new StringBuilder(); sb.append(a); sb.append(""); system.out.println(sb.toString()); } Wh...