Weekend Sale Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: pass65

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

Questions 4

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 5

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 6

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 7

Given:

java

package vehicule.parent;

public class Car {

protected String brand = "Peugeot";

}

and

java

package vehicule.child;

import vehicule.parent.Car;

public class MiniVan extends Car {

public static void main(String[] args) {

Car car = new Car();

car.brand = "Peugeot 807";

System.out.println(car.brand);

}

}

What is printed?

Options:

A.

Peugeot

B.

Peugeot 807

C.

An exception is thrown at runtime.

D.

Compilation fails.

Buy Now
Questions 8

What do the following print?

java

public class DefaultAndStaticMethods {

public static void main(String[] args) {

WithStaticMethod.print();

}

}

interface WithDefaultMethod {

default void print() {

System.out.print("default");

}

}

interface WithStaticMethod extends WithDefaultMethod {

static void print() {

System.out.print("static");

}

}

Options:

A.

nothing

B.

default

C.

Compilation fails

D.

static

Buy Now
Questions 9

Which of the following can be the body of a lambda expression?

Options:

A.

Two statements

B.

An expression and a statement

C.

A statement block

D.

None of the above

E.

Two expressions

Buy Now
Questions 10

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 11

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 12

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
Questions 13

Given:

java

var hauteCouture = new String[]{ "Chanel", "Dior", "Louis Vuitton" };

var i = 0;

do {

System.out.print(hauteCouture[i] + " ");

} while (i++ > 0);

What is printed?

Options:

A.

Chanel

B.

Chanel Dior Louis Vuitton

C.

An ArrayIndexOutOfBoundsException is thrown at runtime.

D.

Compilation fails.

Buy Now
Questions 14

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?

Options:

A.

abc

B.

An exception is thrown.

C.

Compilation fails.

D.

ABC

Buy Now
Questions 15

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

Options:

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.

Buy Now
Questions 16

Given:

java

interface SmartPhone {

boolean ring();

}

class Iphone15 implements SmartPhone {

boolean isRinging;

boolean ring() {

isRinging = !isRinging;

return isRinging;

}

}

Choose the right statement.

Options:

A.

Iphone15 class does not compile

B.

Everything compiles

C.

SmartPhone interface does not compile

D.

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

Buy Now
Questions 17

Given:

java

CopyOnWriteArrayList list = new CopyOnWriteArrayList<>();

list.add("A");

list.add("B");

list.add("C");

// Writing in one thread

new Thread(() -> {

list.add("D");

System.out.println("Element added: D");

}).start();

// Reading in another thread

new Thread(() -> {

for (String element : list) {

System.out.println("Read element: " + element);

}

}).start();

What is printed?

Options:

A.

It prints all elements, including changes made during iteration.

B.

It prints all elements, but changes made during iteration may not be visible.

C.

It throws an exception.

D.

Compilation fails.

Buy Now
Questions 18

Given:

java

public class Versailles {

int mirrorsCount;

int gardensHectares;

void Versailles() { // n1

this.mirrorsCount = 17;

this.gardensHectares = 800;

System.out.println("Hall of Mirrors has " + mirrorsCount + " mirrors.");

System.out.println("The gardens cover " + gardensHectares + " hectares.");

}

public static void main(String[] args) {

var castle = new Versailles(); // n2

}

}

What is printed?

Options:

A.

nginx

Hall of Mirrors has 17 mirrors.

The gardens cover 800 hectares.

B.

Nothing

C.

An exception is thrown at runtime.

D.

Compilation fails at line n1.

E.

Compilation fails at line n2.

Buy Now
Questions 19

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 20

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 21

Given:

java

public class Test {

public static void main(String[] args) throws IOException {

Path p1 = Path.of("f1.txt");

Path p2 = Path.of("f2.txt");

Files.move(p1, p2);

Files.delete(p1);

}

}

In which case does the given program throw an exception?

Options:

A.

Neither files f1.txt nor f2.txt exist

B.

Both files f1.txt and f2.txt exist

C.

An exception is always thrown

D.

File f2.txt exists while file f1.txt doesn't

E.

File f1.txt exists while file f2.txt doesn't

Buy Now
Questions 22

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 23

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 24

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 25

Given:

java

var now = LocalDate.now();

var format1 = new DateTimeFormatter(ISO_WEEK_DATE);

var format2 = DateTimeFormatter.ISO_WEEK_DATE;

var format3 = new DateFormat(WEEK_OF_YEAR_FIELD);

var format4 = DateFormat.getDateInstance(WEEK_OF_YEAR_FIELD);

System.out.println(now.format(REPLACE_HERE));

Which variable prints 2025-W01-2 (present-day is 12/31/2024)?

Options:

A.

format4

B.

format2

C.

format3

D.

format1

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

PDF + Testing Engine

$57.75  $164.99

Testing Engine

$43.75  $124.99
buy now 1z0-830 testing engine

PDF (Q&A)

$36.75  $104.99
buy now 1z0-830 pdf