Weekend Sale 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: best70

1z0-830 Java SE 21 Developer Professional Questions and Answers

Questions 4

Given:

java

List l1 = new ArrayList<>(List.of("a", "b"));

List l2 = new ArrayList<>(Collections.singletonList("c"));

Collections.copy(l1, l2);

l2.set(0, "d");

System.out.println(l1);

What is the output of the given code fragment?

Options:

A.

[a, b]

B.

[d, b]

C.

[c, b]

D.

An UnsupportedOperationException is thrown

E.

An IndexOutOfBoundsException is thrown

F.

[d]

Buy Now
Questions 5

Given:

java

var deque = new ArrayDeque<>();

deque.add(1);

deque.add(2);

deque.add(3);

deque.add(4);

deque.add(5);

System.out.print(deque.peek() + " ");

System.out.print(deque.poll() + " ");

System.out.print(deque.pop() + " ");

System.out.print(deque.element() + " ");

What is printed?

Options:

A.

1 1 1 1

B.

1 5 5 1

C.

1 1 2 3

D.

1 1 2 2

E.

5 5 2 3

Buy Now
Questions 6

Given:

java

public class ExceptionPropagation {

public static void main(String[] args) {

try {

thrower();

System.out.print("Dom Pérignon, ");

} catch (Exception e) {

System.out.print("Chablis, ");

} finally {

System.out.print("Saint-Émilion");

}

}

static int thrower() {

try {

int i = 0;

return i / i;

} catch (NumberFormatException e) {

System.out.print("Rosé");

return -1;

} finally {

System.out.print("Beaujolais Nouveau, ");

}

}

}

What is printed?

Options:

A.

Saint-Émilion

B.

Beaujolais Nouveau, Chablis, Saint-Émilion

C.

Beaujolais Nouveau, Chablis, Dom Pérignon, Saint-Émilion

D.

Rosé

Buy Now
Questions 7

Given:

java

Period p = Period.between(

LocalDate.of(2023, Month.MAY, 4),

LocalDate.of(2024, Month.MAY, 4));

System.out.println(p);

Duration d = Duration.between(

LocalDate.of(2023, Month.MAY, 4),

LocalDate.of(2024, Month.MAY, 4));

System.out.println(d);

What is the output?

Options:

A.

P1Y

PT8784H

B.

PT8784H

P1Y

C.

UnsupportedTemporalTypeException

D.

P1Y

UnsupportedTemporalTypeException

Buy Now
Questions 8

Which methods compile?

Options:

A.

```java public List getListSuper() { return new ArrayList(); }

csharp

B.

```java

public List getListExtends() {

return new ArrayList();

}

C.

```java public List getListExtends() { return new ArrayList(); }

csharp

D.

```java

public List getListSuper() {

return new ArrayList();

}

Buy Now
Questions 9

Given:

java

StringBuffer us = new StringBuffer("US");

StringBuffer uk = new StringBuffer("UK");

Stream stream = Stream.of(us, uk);

String output = stream.collect(Collectors.joining("-", "=", ""));

System.out.println(output);

What is the given code fragment's output?

Options:

A.

US-UK

B.

An exception is thrown.

C.

-US=UK

D.

=US-UK

E.

Compilation fails.

F.

US=UK

Buy Now
Questions 10

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

Buy Now
Questions 11

Given:

java

List integers = List.of(0, 1, 2);

integers.stream()

.peek(System.out::print)

.limit(2)

.forEach(i -> {});

What is the output of the given code fragment?

Options:

A.

Compilation fails

B.

An exception is thrown

C.

01

D.

012

E.

Nothing

Buy Now
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]

Buy Now
Questions 13

You are working on a module named perfumery.shop that depends on another module named perfumery.provider.

The perfumery.shop module should also make its package perfumery.shop.eaudeparfum available to other modules.

Which of the following is the correct file to declare the perfumery.shop module?

Options:

A.

File name: module-info.perfumery.shop.java

java

module perfumery.shop {

requires perfumery.provider;

exports perfumery.shop.eaudeparfum.*;

}

B.

File name: module-info.java

java

module perfumery.shop {

requires perfumery.provider;

exports perfumery.shop.eaudeparfum;

}

C.

File name: module.java

java

module shop.perfumery {

requires perfumery.provider;

exports perfumery.shop.eaudeparfum;

}

Buy Now
Questions 14

Given:

java

double amount = 42_000.00;

NumberFormat format = NumberFormat.getCompactNumberInstance(Locale.FRANCE, NumberFormat.Style.SHORT);

System.out.println(format.format(amount));

What is the output?

Options:

A.

42000E

B.

42 000,00 €

C.

42000

D.

42 k

Buy Now
Questions 15

What does the following code print?

java

import java.util.stream.Stream;

public class StreamReduce {

public static void main(String[] args) {

Stream stream = Stream.of("J", "a", "v", "a");

System.out.print(stream.reduce(String::concat));

}

}

Options:

A.

Optional[Java]

B.

Java

C.

null

D.

Compilation fails

Buy Now
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

Buy Now
Questions 17

Given:

java

Stream strings = Stream.of("United", "States");

BinaryOperator operator = (s1, s2) -> s1.concat(s2.toUpperCase());

String result = strings.reduce("-", operator);

System.out.println(result);

What is the output of this code fragment?

Options:

A.

United-States

B.

United-STATES

C.

UNITED-STATES

D.

-UnitedStates

E.

-UNITEDSTATES

F.

-UnitedSTATES

G.

UnitedStates

Buy Now
Questions 18

Given:

java

try (FileOutputStream fos = new FileOutputStream("t.tmp");

ObjectOutputStream oos = new ObjectOutputStream(fos)) {

fos.write("Today");

fos.writeObject("Today");

oos.write("Today");

oos.writeObject("Today");

} catch (Exception ex) {

// handle exception

}

Which statement compiles?

Options:

A.

fos.write("Today");

B.

fos.writeObject("Today");

C.

oos.write("Today");

D.

oos.writeObject("Today");

Buy Now
Questions 19

Which of the following statements are correct?

Options:

A.

You can use 'private' access modifier with all kinds of classes

B.

You can use 'protected' access modifier with all kinds of classes

C.

You can use 'public' access modifier with all kinds of classes

D.

You can use 'final' modifier with all kinds of classes

E.

None

Buy Now
Questions 20

How would you create a ConcurrentHashMap configured to allow a maximum of 10 concurrent writer threads and an initial capacity of 42?

Which of the following options meets this requirement?

Options:

A.

var concurrentHashMap = new ConcurrentHashMap(42);

B.

None of the suggestions.

C.

var concurrentHashMap = new ConcurrentHashMap();

D.

var concurrentHashMap = new ConcurrentHashMap(42, 10);

E.

var concurrentHashMap = new ConcurrentHashMap(42, 0.88f, 10);

Buy Now
Questions 21

Which of the following java.io.Console methods doesnotexist?

Options:

A.

read()

B.

reader()

C.

readLine()

D.

readLine(String fmt, Object... args)

E.

readPassword()

F.

readPassword(String fmt, Object... args)

Buy Now
Questions 22

Given:

java

List frenchAuthors = new ArrayList<>();

frenchAuthors.add("Victor Hugo");

frenchAuthors.add("Gustave Flaubert");

Which compiles?

Options:

A.

Map<String, ArrayList<String>> authorsMap1 = new HashMap<>();

java

authorsMap1.put("FR", frenchAuthors);

B.

Map<String, ? extends List<String>> authorsMap2 = new HashMap<String, ArrayList<String>>();

java

authorsMap2.put("FR", frenchAuthors);

C.

var authorsMap3 = new HashMap<>();

java

authorsMap3.put("FR", frenchAuthors);

D.

Map<String, List<String>> authorsMap4 = new HashMap<String, ArrayList<String>>();

java

authorsMap4.put("FR", frenchAuthors);

E.

Map<String, List<String>> authorsMap5 = new HashMap<String, List<String>>();

java

authorsMap5.put("FR", frenchAuthors);

Buy Now
Questions 23

Consider the following methods to load an implementation of MyService using ServiceLoader. Which of the methods are correct? (Choose all that apply)

Options:

A.

MyService service = ServiceLoader.load(MyService.class).iterator().next();

B.

MyService service = ServiceLoader.load(MyService.class).findFirst().get();

C.

MyService service = ServiceLoader.getService(MyService.class);

D.

MyService service = ServiceLoader.services(MyService.class).getFirstInstance();

Buy Now
Questions 24

Given:

java

List cannesFestivalfeatureFilms = LongStream.range(1, 1945)

.boxed()

.toList();

try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {

cannesFestivalfeatureFilms.stream()

.limit(25)

.forEach(film -> executor.submit(() -> {

System.out.println(film);

}));

}

What is printed?

Options:

A.

Numbers from 1 to 25 sequentially

B.

Numbers from 1 to 25 randomly

C.

Numbers from 1 to 1945 randomly

D.

An exception is thrown at runtime

E.

Compilation fails

Buy Now
Questions 25

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);

Buy Now
Exam Code: 1z0-830
Exam Name: Java SE 21 Developer Professional
Last Update: Jul 13, 2025
Questions: 84

PDF + Testing Engine

$140

Testing Engine

$105

PDF (Q&A)

$90