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

1z0-830 Exam Dumps - Oracle Java SE Questions and Answers

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?

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
Question # 15

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
Question # 16

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
Question # 17

Given:

java

var sList = new CopyOnWriteArrayList();

Which of the following statements is correct?

Options:

A.

The CopyOnWriteArrayList class is a thread-safe variant of ArrayList where all mutative operations are implemented by making a fresh copy of the underlying array.

B.

The CopyOnWriteArrayList class is not thread-safe and does not prevent interference amongconcurrent threads.

C.

The CopyOnWriteArrayList class’s iterator reflects all additions, removals, or changes to the list since the iterator was created.

D.

The CopyOnWriteArrayList class does not allow null elements.

E.

Element-changing operations on iterators of CopyOnWriteArrayList, such as remove, set, and add, are supported and do not throw UnsupportedOperationException.

Buy Now
Question # 18

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
Question # 19

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
Question # 20

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
Question # 21

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
Question # 22

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?

Options:

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

Buy Now
Question # 23

Given:

java

Optional o1 = Optional.empty();

Optional o2 = Optional.of(1);

Optional o3 = Stream.of(o1, o2)

.filter(Optional::isPresent)

.findAny()

.flatMap(o -> o);

System.out.println(o3.orElse(2));

What is the given code fragment's output?

Options:

A.

1

B.

2

C.

Optional.empty

D.

0

E.

An exception is thrown

F.

Optional[1]

G.

Compilation fails

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

1z0-830 PDF

$25.5  $84.99
1z0-830 Engine

1z0-830 Testing Engine

$28.5  $94.99
1z0-830 PDF + Engine

1z0-830 PDF + Testing Engine

$40.5  $134.99