Summer Special 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: bestdeal

Free Oracle 1z0-830 Practice Exam with Questions & Answers | Set: 2

Questions 11

Given:

java

Object myVar = 0;

String print = switch (myVar) {

case int i -> "integer";

case long l -> "long";

case String s -> "string";

default -> "";

};

System.out.println(print);

What is printed?

Options:
A.

integer

B.

long

C.

string

D.

nothing

E.

It throws an exception at runtime.

F.

Compilation fails.

Oracle 1z0-830 Premium Access
Questions 12

Given:

java

var frenchCities = new TreeSet();

frenchCities.add("Paris");

frenchCities.add("Marseille");

frenchCities.add("Lyon");

frenchCities.add("Lille");

frenchCities.add("Toulouse");

System.out.println(frenchCities.headSet("Marseille"));

What will be printed?

Options:
A.

[Paris]

B.

[Paris, Toulouse]

C.

[Lille, Lyon]

D.

Compilation fails

E.

[Lyon, Lille, Toulouse]

Questions 13

Which of the following statements oflocal variables declared with varareinvalid?(Choose 4)

Options:
A.

var a = 1;(Valid: var correctly infers int)

B.

var b = 2, c = 3.0;

C.

var d[] = new int[4];

D.

var e;

E.

var f = { 6 };

F.

var h = (g = 7);

Questions 14

Which of the followingisn'ta correct way to write a string to a file?

Options:
A.

java

Path path = Paths.get("file.txt");

byte[] strBytes = "Hello".getBytes();

Files.write(path, strBytes);

B.

java

try (BufferedWriter writer = new BufferedWriter("file.txt")) {

writer.write("Hello");

}

C.

java

try (FileOutputStream outputStream = new FileOutputStream("file.txt")) {

byte[] strBytes = "Hello".getBytes();

outputStream.write(strBytes);

}

D.

java

try (PrintWriter printWriter = new PrintWriter("file.txt")) {

printWriter.printf("Hello %s", "James");

}

E.

None of the suggestions

F.

java

try (FileWriter writer = new FileWriter("file.txt")) {

writer.write("Hello");

}

Questions 15

Which two of the following aren't the correct ways to create a Stream?

Options:
A.

Stream stream = Stream.of("a");

B.

Stream stream = Stream.ofNullable("a");

C.

Stream stream = Stream.generate(() -> "a");

D.

Stream stream = Stream.of();

E.

Stream stream = new Stream();

F.

Stream stream = Stream.builder().add("a").build();

G.

Stream stream = Stream.empty();

Questions 16

Which of the following isn't a valid option of the jdeps command?

Options:
A.

--check-deps

B.

--generate-open-module

C.

--list-deps

D.

--generate-module-info

E.

--print-module-deps

F.

--list-reduced-deps

Questions 17

Given:

java

StringBuilder result = Stream.of("a", "b")

.collect(

() -> new StringBuilder("c"),

StringBuilder::append,

(a, b) -> b.append(a)

);

System.out.println(result);

What is the output of the given code fragment?

Options:
A.

cbca

B.

acb

C.

cacb

D.

abc

E.

bca

F.

cba

G.

bac

Questions 18

Given:

java

System.out.print(Boolean.logicalAnd(1 == 1, 2 < 1));

System.out.print(Boolean.logicalOr(1 == 1, 2 < 1));

System.out.print(Boolean.logicalXor(1 == 1, 2 < 1));

What is printed?

Options:
A.

truetruefalse

B.

falsetruetrue

C.

truefalsetrue

D.

truetruetrue

E.

Compilation fails

Questions 19

Given:

java

Runnable task1 = () -> System.out.println("Executing Task-1");

Callable task2 = () -> {

System.out.println("Executing Task-2");

return "Task-2 Finish.";

};

ExecutorService execService = Executors.newCachedThreadPool();

// INSERT CODE HERE

execService.awaitTermination(3, TimeUnit.SECONDS);

execService.shutdownNow();

Which of the following statements, inserted in the code above, printsboth:

"Executing Task-2" and "Executing Task-1"?

Options:
A.

execService.call(task1);

B.

execService.call(task2);

C.

execService.execute(task1);

D.

execService.execute(task2);

E.

execService.run(task1);

F.

execService.run(task2);

G.

execService.submit(task1);

Questions 20

A module com.eiffeltower.shop with the related sources in the src directory.

That module requires com.eiffeltower.membership, available in a JAR located in the lib directory.

What is the command to compile the module com.eiffeltower.shop?

Options:
A.

bash

CopyEdit

javac -source src -p lib/com.eiffel.membership.jar -d out -m com.eiffeltower.shop

B.

css

CopyEdit

javac --module-source-path src -p lib/com.eiffel.membership.jar -d out -m com.eiffeltower.shop

C.

css

CopyEdit

javac --module-source-path src -p lib/com.eiffel.membership.jar -s out -m com.eiffeltower.shop

D.

css

CopyEdit

javac -path src -p lib/com.eiffel.membership.jar -d out -m com.eiffeltower.shop

Exam Code: 1z0-830
Certification Provider: Oracle
Exam Name: Java SE 21 Developer Professional
Last Update: Jul 15, 2025
Questions: 84
PDF + Testing Engine
$164.99
$66
Testing Engine
$124.99
$50
PDF (Q&A)
$104.99
$42