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

Given:

java

package com.vv;

import java.time.LocalDate;

public class FetchService {

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

FetchService service = new FetchService();

String ack = service.fetch();

LocalDate date = service.fetch();

System.out.println(ack + " the " + date.toString());

}

public String fetch() {

return "ok";

}

public LocalDate fetch() {

return LocalDate.now();

}

}

What will be the output?

A.

ok the 2024-07-10T07:17:45.523939600

B.

Compilation fails

C.

An exception is thrown

D.

ok the 2024-07-10

Full Access
Question # 10

Given:

java

Period p = Period.between(

LocalDate.of(2023, Month.MAY, 4),

LocalDate.of(2024, Month.MAY, 4));

System.out.println(p);

Duration d = Duration.between(

LocalDate.of(2023, Month.MAY, 4),

LocalDate.of(2024, Month.MAY, 4));

System.out.println(d);

What is the output?

A.

P1Y

PT8784H

B.

PT8784H

P1Y

C.

UnsupportedTemporalTypeException

D.

P1Y

UnsupportedTemporalTypeException

Full Access
Question # 11

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)

A.

array1

B.

array2

C.

array3

D.

array4

E.

array5

Full Access
Question # 12

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?

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.

Full Access
Question # 13

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?

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.

Full Access
Question # 14

Given:

java

StringBuffer us = new StringBuffer("US");

StringBuffer uk = new StringBuffer("UK");

Stream stream = Stream.of(us, uk);

String output = stream.collect(Collectors.joining("-", "=", ""));

System.out.println(output);

What is the given code fragment's output?

A.

US-UK

B.

An exception is thrown.

C.

-US=UK

D.

=US-UK

E.

Compilation fails.

F.

US=UK

Full Access
Question # 15

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?

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

Full Access
Question # 16

Given:

java

DoubleStream doubleStream = DoubleStream.of(3.3, 4, 5.25, 6.66);

Predicate doublePredicate = d -> d < 5;

System.out.println(doubleStream.anyMatch(doublePredicate));

What is printed?

A.

Compilation fails

B.

true

C.

false

D.

An exception is thrown at runtime

E.

3.3

Full Access
Go to page: