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

1z0-830 PDF

$38.5

$109.99

3 Months Free Update

  • Printable Format
  • Value of Money
  • 100% Pass Assurance
  • Verified Answers
  • Researched by Industry Experts
  • Based on Real Exams Scenarios
  • 100% Real Questions

1z0-830 PDF + Testing Engine

$61.6

$175.99

3 Months Free Update

  • Exam Name: Java SE 21 Developer Professional
  • Last Update: Jul 8, 2025
  • Questions and Answers: 84
  • Free Real Questions Demo
  • Recommended by Industry Experts
  • Best Economical Package
  • Immediate Access

1z0-830 Engine

$46.2

$131.99

3 Months Free Update

  • Best Testing Engine
  • One Click installation
  • Recommended by Teachers
  • Easy to use
  • 3 Modes of Learning
  • State of Art Technology
  • 100% Real Questions included

1z0-830 Practice Exam Questions with Answers Java SE 21 Developer Professional Certification

Question # 6

Given:

java

String colors = "red\n" +

"green\n" +

"blue\n";

Which text block can replace the above code?

A.

java

String colors = """

red \

green\

blue \

""";

B.

java

String colors = """

red \s

green\s

blue \s

""";

C.

java

String colors = """

red \t

green\t

blue \t

""";

D.

java

String colors = """

red

green

blue

""";

E.

None of the propositions

Full Access
Question # 7

Given:

java

interface Calculable {

long calculate(int i);

}

public class Test {

public static void main(String[] args) {

Calculable c1 = i -> i + 1; // Line 1

Calculable c2 = i -> Long.valueOf(i); // Line 2

Calculable c3 = i -> { throw new ArithmeticException(); }; // Line 3

}

}

Which lines fail to compile?

A.

Line 1 and line 3

B.

Line 2 only

C.

Line 1 only

D.

Line 1 and line 2

E.

Line 2 and line 3

F.

Line 3 only

G.

The program successfully compiles

Full Access
Question # 8

Given a properties file on the classpath named Person.properties with the content:

ini

name=James

And:

java

public class Person extends ListResourceBundle {

protected Object[][] getContents() {

return new Object[][]{

{"name", "Jeanne"}

};

}

}

And:

java

public class Test {

public static void main(String[] args) {

ResourceBundle bundle = ResourceBundle.getBundle("Person");

String name = bundle.getString("name");

System.out.println(name);

}

}

What is the given program's output?

A.

MissingResourceException

B.

Compilation fails

C.

James

D.

JeanneJames

E.

JamesJeanne

F.

Jeanne

Full Access
Question # 9

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?

A.

integer

B.

long

C.

string

D.

nothing

E.

It throws an exception at runtime.

F.

Compilation fails.

Full Access
Question # 10

Which of the following doesnotexist?

A.

BooleanSupplier

B.

DoubleSupplier

C.

LongSupplier

D.

Supplier<T>

E.

BiSupplier<T, U, R>

F.

They all exist.

Full Access
Question # 11

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?

A.

Saint-Émilion

B.

Beaujolais Nouveau, Chablis, Saint-Émilion

C.

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

D.

Rosé

Full Access
Question # 12

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?

A.

fos.write("Today");

B.

fos.writeObject("Today");

C.

oos.write("Today");

D.

oos.writeObject("Today");

Full Access
Question # 13

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?

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

Full Access
Question # 14

Given:

java

void verifyNotNull(Object input) {

boolean enabled = false;

assert enabled = true;

assert enabled;

System.out.println(input.toString());

assert input != null;

}

When does the given method throw a NullPointerException?

A.

A NullPointerException is never thrown

B.

Only if assertions are enabled and the input argument is null

C.

Only if assertions are disabled and the input argument is null

D.

Only if assertions are enabled and the input argument isn't null

E.

Only if assertions are disabled and the input argument isn't null

Full Access
Question # 15

Given:

java

public class OuterClass {

String outerField = "Outer field";

class InnerClass {

void accessMembers() {

System.out.println(outerField);

}

}

public static void main(String[] args) {

System.out.println("Inner class:");

System.out.println("------------");

OuterClass outerObject = new OuterClass();

InnerClass innerObject = new InnerClass(); // n1

innerObject.accessMembers(); // n2

}

}

What is printed?

A.

markdown

Inner class:

------------

Outer field

B.

Nothing

C.

An exception is thrown at runtime.

D.

Compilation fails at line n1.

E.

Compilation fails at line n2.

Full Access
Question # 16

Given:

java

public class SpecialAddition extends Addition implements Special {

public static void main(String[] args) {

System.out.println(new SpecialAddition().add());

}

int add() {

return --foo + bar--;

}

}

class Addition {

int foo = 1;

}

interface Special {

int bar = 1;

}

What is printed?

A.

0

B.

1

C.

2

D.

It throws an exception at runtime.

E.

Compilation fails.

Full Access
Question # 17

Which of the following statements is correct about a final class?

A.

The final keyword in its declaration must go right before the class keyword.

B.

It must contain at least a final method.

C.

It cannot be extended by any other class.

D.

It cannot implement any interface.

E.

It cannot extend another class.

Full Access
Question # 18

Which methods compile?

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

}

Full Access
Question # 19

Given:

java

public static void main(String[] args) {

try {

throw new IOException();

} catch (IOException e) {

throw new RuntimeException();

} finally {

throw new ArithmeticException();

}

}

What is the output?

A.

Compilation fails

B.

IOException

C.

RuntimeException

D.

ArithmeticException

Full Access
Question # 20

Given:

java

Deque deque = new ArrayDeque<>();

deque.offer(1);

deque.offer(2);

var i1 = deque.peek();

var i2 = deque.poll();

var i3 = deque.peek();

System.out.println(i1 + " " + i2 + " " + i3);

What is the output of the given code fragment?

A.

1 2 1

B.

An exception is thrown.

C.

2 2 1

D.

2 1 2

E.

1 2 2

F.

1 1 2

G.

2 1 1

Full Access
Question # 21

Given:

java

interface SmartPhone {

boolean ring();

}

class Iphone15 implements SmartPhone {

boolean isRinging;

boolean ring() {

isRinging = !isRinging;

return isRinging;

}

}

Choose the right statement.

A.

Iphone15 class does not compile

B.

Everything compiles

C.

SmartPhone interface does not compile

D.

An exception is thrown at running Iphone15.ring();

Full Access
Question # 22

What do the following print?

java

import java.time.Duration;

public class DividedDuration {

public static void main(String[] args) {

var day = Duration.ofDays(2);

System.out.print(day.dividedBy(8));

}

}

A.

PT6H

B.

PT0H

C.

It throws an exception

D.

PT0D

E.

Compilation fails

Full Access
Question # 23

Which StringBuilder variable fails to compile?

java

public class StringBuilderInstantiations {

public static void main(String[] args) {

var stringBuilder1 = new StringBuilder();

var stringBuilder2 = new StringBuilder(10);

var stringBuilder3 = new StringBuilder("Java");

var stringBuilder4 = new StringBuilder(new char[]{'J', 'a', 'v', 'a'});

}

}

A.

None of them

B.

stringBuilder4

C.

stringBuilder1

D.

stringBuilder3

E.

stringBuilder2

Full Access
Question # 24

Given:

java

List abc = List.of("a", "b", "c");

abc.stream()

.forEach(x -> {

x = x.toUpperCase();

});

abc.stream()

.forEach(System.out::print);

What is the output?

A.

abc

B.

An exception is thrown.

C.

Compilation fails.

D.

ABC

Full Access
Question # 25

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?

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;

}

Full Access