Special Summer Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: scxmas70

1z0-830 Exam Dumps - Java SE 21 Developer Professional

Go to page:
Question # 4

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 # 5

Given:

java

DoubleSummaryStatistics stats1 = new DoubleSummaryStatistics();

stats1.accept(4.5);

stats1.accept(6.0);

DoubleSummaryStatistics stats2 = new DoubleSummaryStatistics();

stats2.accept(3.0);

stats2.accept(8.5);

stats1.combine(stats2);

System.out.println("Sum: " + stats1.getSum() + ", Max: " + stats1.getMax() + ", Avg: " + stats1.getAverage());

What is printed?

A.

Sum: 22.0, Max: 8.5, Avg: 5.5

B.

Sum: 22.0, Max: 8.5, Avg: 5.0

C.

An exception is thrown at runtime.

D.

Compilation fails.

Full Access
Question # 6

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?

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.

Full Access
Question # 7

Given:

java

ExecutorService service = Executors.newFixedThreadPool(2);

Runnable task = () -> System.out.println("Task is complete");

service.submit(task);

service.shutdown();

service.submit(task);

What happens when executing the given code fragment?

A.

It prints "Task is complete" once and throws an exception.

B.

It prints "Task is complete" twice and throws an exception.

C.

It exits normally without printing anything to the console.

D.

It prints "Task is complete" twice, then exits normally.

E.

It prints "Task is complete" once, then exits normally.

Full Access
Question # 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");

}

}

A.

nothing

B.

default

C.

Compilation fails

D.

static

Full Access
Go to page: