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

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

Questions 4

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 5

Given:

var cabarets = new TreeMap<>();

cabarets.put(1, "Moulin Rouge");

cabarets.put(2, "Crazy Horse");

cabarets.put(3, "Paradis Latin");

cabarets.put(4, "Le Lido");

cabarets.put(5, "Folies Bergère");

System.out.println(cabarets.subMap(2, true, 5, false));

What is printed?

Options:

A.

CopyEdit

{2=Crazy Horse, 3=Paradis Latin, 4=Le Lido, 5=Folies Bergère}

B.

{2=Crazy Horse, 3=Paradis Latin, 4=Le Lido}

C.

{}

D.

An exception is thrown at runtime.

E.

Compilation fails.

Buy Now
Questions 6

Given:

java

String textBlock = """

j \

a \t

v \s

a \

""";

System.out.println(textBlock.length());

What is the output?

Options:

A.

11

B.

12

C.

14

D.

10

Buy Now
Questions 7

Given:

java

final Stream strings =

Files.readAllLines(Paths.get("orders.csv"));

strings.skip(1)

.limit(2)

.forEach(System.out::println);

And that the orders.csv file contains:

mathematica

OrderID,Customer,Product,Quantity,Price

1,Kylian Mbappé,Keyboard,2,25.50

2,Teddy Riner,Mouse,1,15.99

3,Sebastien Loeb,Monitor,1,199.99

4,Antoine Griezmann,Headset,3,45.00

What is printed?

Options:

A.

arduino

1,Kylian Mbappé,Keyboard,2,25.50

2,Teddy Riner,Mouse,1,15.99

3,Sebastien Loeb,Monitor,1,199.99

4,Antoine Griezmann,Headset,3,45.00

B.

arduino

1,Kylian Mbappé,Keyboard,2,25.50

2,Teddy Riner,Mouse,1,15.99

C.

arduino

2,Teddy Riner,Mouse,1,15.99

3,Sebastien Loeb,Monitor,1,199.99

D.

An exception is thrown at runtime.

E.

Compilation fails.

Buy Now
Questions 8

Given:

java

public class BoomBoom implements AutoCloseable {

public static void main(String[] args) {

try (BoomBoom boomBoom = new BoomBoom()) {

System.out.print("bim ");

throw new Exception();

} catch (Exception e) {

System.out.print("boom ");

}

}

@Override

public void close() throws Exception {

System.out.print("bam ");

throw new RuntimeException();

}

}

What is printed?

Options:

A.

bim boom bam

B.

bim bam boom

C.

bim boom

D.

bim bam followed by an exception

E.

Compilation fails.

Buy Now
Questions 9

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?

Options:

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

Buy Now
Questions 10

Given:

java

LocalDate localDate = LocalDate.of(2020, 8, 8);

Date date = java.sql.Date.valueOf(localDate);

DateFormat formatter = new SimpleDateFormat(/* pattern */);

String output = formatter.format(date);

System.out.println(output);

It's known that the given code prints out "August 08".

Which of the following should be inserted as the pattern?

Options:

A.

MM d

B.

MM dd

C.

MMMM dd

D.

MMM dd

Buy Now
Questions 11

Which of the following suggestions compile?(Choose two.)

Options:

A.

java

sealed class Figure permits Rectangle {}

final class Rectangle extends Figure {

float length, width;

}

B.

java

sealed class Figure permits Rectangle {}

public class Rectangle extends Figure {

float length, width;

}

C.

java

public sealed class Figure

permits Circle, Rectangle {}

final sealed class Circle extends Figure {

float radius;

}

non-sealed class Rectangle extends Figure {

float length, width;

}

D.

java

public sealed class Figure

permits Circle, Rectangle {}

final class Circle extends Figure {

float radius;

}

non-sealed class Rectangle extends Figure {

float length, width;

}

Buy Now
Questions 12

Given:

java

var array1 = new String[]{ "foo", "bar", "buz" };

var array2[] = { "foo", "bar", "buz" };

var array3 = new String[3] { "foo", "bar", "buz" };

var array4 = { "foo", "bar", "buz" };

String array5[] = new String[]{ "foo", "bar", "buz" };

Which arrays compile? (Select 2)

Options:

A.

array1

B.

array2

C.

array3

D.

array4

E.

array5

Buy Now
Questions 13

Which of the following methods of java.util.function.Predicate aredefault methods?

Options:

A.

and(Predicate<? super T> other)

B.

isEqual(Object targetRef)

C.

negate()

D.

not(Predicate<? super T> target)

E.

or(Predicate<? super T> other)

F.

test(T t)

Buy Now
Questions 14

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

}

}

Options:

A.

PT6H

B.

PT0H

C.

It throws an exception

D.

PT0D

E.

Compilation fails

Buy Now
Questions 15

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?

Options:

A.

Compilation fails

B.

IOException

C.

RuntimeException

D.

ArithmeticException

Buy Now
Questions 16

Given:

java

var counter = 0;

do {

System.out.print(counter + " ");

} while (++counter < 3);

What is printed?

Options:

A.

0 1 2 3

B.

0 1 2

C.

1 2 3 4

D.

1 2 3

E.

An exception is thrown.

F.

Compilation fails.

Buy Now
Questions 17

Given:

java

sealed class Vehicle permits Car, Bike {

}

non-sealed class Car extends Vehicle {

}

final class Bike extends Vehicle {

}

public class SealedClassTest {

public static void main(String[] args) {

Class vehicleClass = Vehicle.class;

Class carClass = Car.class;

Class bikeClass = Bike.class;

System.out.print("Is Vehicle sealed? " + vehicleClass.isSealed() +

"; Is Car sealed? " + carClass.isSealed() +

"; Is Bike sealed? " + bikeClass.isSealed());

}

}

What is printed?

Options:

A.

Is Vehicle sealed? true; Is Car sealed? true; Is Bike sealed? true

B.

Is Vehicle sealed? false; Is Car sealed? false; Is Bike sealed? false

C.

Is Vehicle sealed? true; Is Car sealed? false; Is Bike sealed? false

D.

Is Vehicle sealed? false; Is Car sealed? true; Is Bike sealed? true

Buy Now
Questions 18

Given:

java

var lyrics = """

Quand il me prend dans ses bras

Qu'il me parle tout bas

Je vois la vie en rose

""";

for ( int i = 0, int j = 3; i < j; i++ ) {

System.out.println( lyrics.lines()

.toList()

.get( i ) );

}

What is printed?

Options:

A.

vbnet

Quand il me prend dans ses bras

Qu'il me parle tout bas

Je vois la vie en rose

B.

Nothing

C.

An exception is thrown at runtime.

D.

Compilation fails.

Buy Now
Questions 19

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 20

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

Buy Now
Questions 21

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?

Options:

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

Buy Now
Questions 22

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 23

Given:

java

String s = " ";

System.out.print("[" + s.strip());

s = " hello ";

System.out.print("," + s.strip());

s = "h i ";

System.out.print("," + s.strip() + "]");

What is printed?

Options:

A.

[ ,hello,h i]

B.

[,hello,h i]

C.

[,hello,hi]

D.

[ , hello ,hi ]

Buy Now
Questions 24

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 25

Given:

java

record WithInstanceField(String foo, int bar) {

double fuz;

}

record WithStaticField(String foo, int bar) {

static double wiz;

}

record ExtendingClass(String foo) extends Exception {}

record ImplementingInterface(String foo) implements Cloneable {}

Which records compile? (Select 2)

Options:

A.

ExtendingClass

B.

WithInstanceField

C.

ImplementingInterface

D.

WithStaticField

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

1z0-830 PDF

$29.75  $84.99
1z0-830 Engine

1z0-830 Testing Engine

$35  $99.99
1z0-830 PDF + Engine

1z0-830 PDF + Testing Engine

$47.25  $134.99