1z0-819Free trialFree trial

By oracle
Aug, 2025

Verified

25Q per page

Question 1

Given:

Image 1

What is the result?

  • A: 2-4
  • B: 0-6 1-5 2-4
  • C: 1-5
  • D: 1-5 2-4
  • E: The compilation fails due to an error in line 1.
  • F: 0-6
  • G: 0-6 2-4

Question 2

Given:

Image 1

What is the result?

  • A: [A, B, C] followed by an exception thrown on line 11.
  • B: [A, B, C] [A, B]
  • C: [A, B, C] [A, B, C]
  • D: On line 9, an exception is thrown at run time.

Question 3

Given TripleThis.java:

Image 1

Compiling TripleThis.java gives this compiler warning:

Note: TripleThis.java uses unchecked or unsafe operations.

Which two replacements remove this compiler warning and prints 12? (Choose two.)

  • A: Replace line 12 with public static void printValue(Function f, int num) {
  • B: Replace line 12 with public static void printValue(Function f, T num) {
  • C: Replace line 9 with Function tripler = x —> { return (Integer) x * 3; }
  • D: Replace line 12 with public static void printValue(Function f, Integer num) {
  • E: Replace line 9 with Function tripler = x -> { return x * 3; }
  • F: Replace line 9 with Function tripler = x -> [ return x * 3; ]

Question 4

Given the code fragment:

Image 1

What change on line 1 will make this code compile?

  • A: Add catch(M | L e)
  • B: Add catch(L e)
  • C: Add catch(N | L | M e)
  • D: Add catch(L | N e)
  • E: Add catch(L | M | N e)

Question 5

Given the code fragment:

Image 1

Which two code snippets inserted independently inside println method print Mondial:domainmodel? (Choose two.)

  • A: Main.prefix + Main.name
  • B: prefix + getName
  • C: Main.prefix + Main.getName()
  • D: new Main().prefix + new Main().name
  • E: prefix + name
  • F: prefix + Main.name

Question 6

Given the code fragment:

Image 1

What is the result?

  • A: [Lettuce, Kale]
  • B: A compilation error is thrown.
  • C: [Lettuce, Kale] [Seabass, Salmon]
  • D: [Kale, Lettuce] [Salmon, Seabass]

Question 7

Given:

Automobile.java -

Image 1

Car.java -

Image 2

What must you do so that the code prints 4?

  • A: Remove the parameter from wheels method in line 3.
  • B: Remove abstract keyword in line 1.
  • C: Replace the code in line 2 with Car ob = new Car();.
  • D: Add @Override annotation at line 2.

Question 8

Which module is required for any application using Swing or AWT?

  • A: java.desktop
  • B: java.prefs
  • C: java.se
  • D: java.logging
  • E: java.rmi

Question 9

Which set of commands is necessary to create and run a custom runtime image from Java source files?

  • A: java,jdeps
  • B: javac,jlink
  • C: javac,jar
  • D: jar,jlink

Question 10

Given the code fragment:

Image 1

Which would cause s to be AQCD?

  • A: s.replace(s.indexOf("B"), s.indexOf("B"), "Q");
  • B: s.replace(s.indexOf("A"), s.indexOf("B"), "Q");
  • C: s.replace(s.indexOf("B"), s.indexOf("C"), "Q");
  • D: s.replace(s.indexOf("A"), s.indexOf("C"), "Q");

Question 11

Given:

Image 1

Which two methods facilitate valid ways to read instance fields? (Choose two.)

  • A: getCCount
  • B: getTCount
  • C: getACount
  • D: getGCount
  • E: getTotalCount

Question 12

Given:

Image 1

To secure this code, you want to make sure that the client code cannot modify the public static fields.

Which code will accomplish this?

  • A:
  • B:
  • C:
  • D:

Question 13

Which module-info.java is correct for a service provider for a print service defined in the PrintServiceAPI module?

  • A: module PrintServiceProvider { requires PrintServiceAPI; exports org.printservice.spi; }
  • B: module PrintServiceProvider { requires PrintServiceAPI; provides org.printservice.spi.Print with com.provider.PrintService; }
  • C: module PrintServiceProvider { requires PrintServiceAPI; uses com.provider.PrintService; }
  • D: module PrintServiceProvider { requires PrintServiceAPI; exports org.printservice.spi.Print with com.provider.PrintService; }

Question 14

Given:

Image 1

and

Image 2

What is the result?

  • A: test:null
  • B: test:1
  • C: A ClassCastException is thrown at runtime.
  • D: null:null
  • E: The compilation fails.

Question 15

Given:

Image 1

Given the directory structure:

Image 2

Given the commands to execute at the Test directory prompt:

Image 3

Which statement is true?

  • A: Create an empty module-info.java file in the Test directory and on execution of the given commands, the program prints:
  • B: On execution of the given commands, the program prints:
  • C: Execute java --module-path pac pac.Hello instead of java -cp pac pac.Hello and on execution the program prints:
  • D: On execution of the given commands, the program prints:

Question 16

Given:

Image 1

and

Image 2

What is the result?

  • A: 214
  • B: 2341
  • C: 234
  • D: 2134

Question 17

Given:

Image 1

Which code fragment added to line 1 enables the code to compile and print Hello Joe?

  • A:
  • B:
  • C:
  • D:

Question 18

Given the code fragment:

Image 1

Which statement at line 1 will print Ping Pong?

  • A:
  • B:
  • C:
  • D:

Question 19

Given the content from the course.txt file:

Image 1

Given the code fragment:

Image 2

Which code fragment at line 1 prints the lines that contain Java from the course.txt file?

  • A:
  • B:
  • C:
  • D:
  • E:

Question 20

Given:

Image 1

What is the output?

  • A: A NullPointerException is thrown at run time.
  • B: null
  • C: Duke
  • D: A NoSuchElementException is thrown at run time.

Question 21

Given:

Image 1

and

Image 2

Which code fragment on line 1 makes the m map contain the employee with the highest salary for each neighborhood?

  • A:
  • B:
  • C:
  • D:

Question 22

Given:

Image 1

Taking into account that the order of the elements is unpredictable, what is the output?

  • A: {am=2, first=1, mismatch=1, second=2}
  • B: {mismatch=2, am=2, first=1, second=1}
  • C: {l=mismatch, 2=am}
  • D: {mismatch=1, am=2, first=1, second=1}

Question 23

Given these declarations:

Image 1

and these two code fragments:

Fragment 1:

Image 2

Fragment 2:

Image 3

Which code fragment is preferred and why?

  • A: Fragment 1 because it is shorter.
  • B: Fragment 2 because it prevents SQL injection.
  • C: Fragment 2 because it explicitly specifies the SQL types of the column values.
  • D: Fragment 1 because it is more performant.

Question 24

Given the code fragment:

Image 1

What is the result?

  • A: EUR -> 0.84 - GBP -> 0.75 - USD -> 1.00 - CNY -> 6.42
  • B: The compilation fails.
  • C: CNY -> 6.42 - EUR -> 0.84 - GBP -> 0.75 - USD -> 1.00
  • D: USD -> 1.00 - GBP -> 0.75 - EUR -> 0.84 - CNY -> 6.42

Question 25

Given:

Image 1

How many LocalDate objects are created in this example?

  • A: 2
  • B: 3
  • C: 4
  • D: 5
Page 1 of 9 • Questions 1-25 of 213

Free preview mode

Enjoy the free questions and consider upgrading to gain full access!