Winter Sale Special 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: ex2p65

Exact2Pass Menu

Question # 4

Given:

Which annotation should be used to remove warnings from compilation?

A.

@SuppressWarnings on the main and print methods

B.

@SuppressWarnings(“unchecked”) on main and @SafeVarargs on the print method

C.

@SuppressWarnings(“rawtypes”) on main and @SafeVarargs on the print method

D.

@SuppressWarnings(“all”) on the main and print methods

Full Access
Question # 5

Given:

Which two statements are true if the method is added to Bar? (Choose two.)

A.

public Collection foo(Collection arg) { ... } overrides Foo.foo.

B.

public Collection foo(Stream arg) { ... } overloads Foo.foo.

C.

public List foo(Collection arg) { ... } overrides Foo.foo.

D.

public Collection foo(Collection arg) { ... } overloads Foo.foo.

E.

public Collection bar(Collection arg) { ... } overloads Foo.foo.

F.

public Iterable foo(Collection arg) { ... } overrides Foo.foo.

Full Access
Question # 6

Which module-info.java is correct for a service provider for a print service defined in the PrintServiceAPI

module?

A.

module PrintServiceProvider {

requires PrintServiceAPI;

exports org.printservice.spi;

}

B.

module PrintServiceProvider {

requires PrintServiceAPI;

provides org.printservice.spi.Print with

com.provider.PrintService;

}

C.

module PrintServiceProvider {

requires PrintServiceAPI;

uses com.provider.PrintService;

}

D.

module PrintServiceProvider {

requires PrintServiceAPI;

exports org.printservice.spi.Print with

D18912E1457D5D1DDCBD40AB3BF70D5D

com.provider.PrintService;

}

Full Access
Question # 7

Given:

What is the result?

A.

5

B.

3

C.

23

D.

25

E.

11

Full Access
Question # 8

Given:

What is the result?

A.

Joe

null

B.

null

Mary

C.

Joe

Marry

D.

null

null

Full Access
Question # 9

Given:

It is required that if p instanceof Pair then p.isValid() returns true.

Which is the smallest set of visibility changes to insure this requirement is met?

A.

setLeft and setRight must be protected.

B.

left and right must be private.

C.

isValid must be public.

D.

left, right, setLeft, and setRight must be private.

Full Access
Question # 10

What is the result?

A.

357

B.

35

C.

235

D.

2357

E.

An ArrayIndexOutOfBoundsException is thrown at runtime.

Full Access
Question # 11

Given:

Which code fragment on line 1 makes the m map contain the employee with the highest salary for each neighborhood?

A)

B)

C)

D)

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Full Access
Question # 12

Which is true?

A.

Code compiles but throws a runtime exception when run.

B.

It prints 666.

C.

The code compiles and runs successfully but with a wrong answer (i.e., a bug).

D.

The code does not compile successfully.

Full Access
Question # 13

Given:

executed with this command:

java Main one two three

What is the output of this class?

A.

The compilation fails.

B.

1) one2) two3) three

C.

A java.lang.ArrayIndexOutOfBoundsException is thrown.

D.

1) one

E.

nothing

Full Access
Question # 14

Given the code fragment:

What change on line 1 will make this code compile?

A.

Add catch (L |N e).

B.

Add catch (L |M N e).

C.

Add catch (L e).

D.

Add catch (N | L | M e).

E.

Add catch (M |L e).

Full Access
Question # 15

Given:

public class X {

}

and

public final class Y extends X {

}

What is the result of compiling these two classes?

A.

The compilation fails because there is no zero args constructor defined in class X.

B.

The compilation fails because either class X or class Y needs to implement the toString() method.

C.

The compilation fails because a final class cannot extend another class.

D.

The compilation succeeds.

Full Access
Question # 16

Given:

What is the output?

A.

null

B.

A NoSuchElementException is thrown at run time.

C.

Duke

D.

A NullPointerException is thrown at run time.

Full Access
Question # 17

Given the declaration:

Examine this code fragment:

/* Loc1 */ class ProcessOrders { ... }

Which two annotations may be applied at Loc1 in the code fragment? (Choose two.)

A.

@Resource(priority=100)

B.

@Resource(priority=0)

C.

@Resource(name=“Customer1”, priority=100)

D.

@Resource(name=“Customer1”)

E.

@Resource

Full Access
Question # 18

Given:

What is the result?

A.

42

B.

The compilation fails due to an error in line 4.

C.

17

D.

The compilation fails due to an error in line 3.

E.

The compilation fails due to an error in line 2.

F.

The compilation fails due to an error in line 1.

G.

The compilation fails due to an error in line 5.

Full Access
Question # 19

Which interface in the java.util.function package can return a primitive type?

A.

ToDoubleFunction

B.

Supplier

C.

BiFunction

D.

LongConsumer

Full Access
Question # 20

Given the code fragment:

Path source = Paths.get(“/repo/a/a.txt”);

Path destination = Paths.get(“/repo”);

Files.move(source, destination); // line 1

Files.delete (source); // line 2

Assuming the source file and destination folder exist, what Is the result?

A.

A java.nio.file.FileAlreadyExistsException is thrown on line 1.

B.

A java.nio.file.NoSuchFileException is thrown on line 2.

C.

A copy of /repo/a/a.txt is moved to the /repo directory and /repo/a/a.txt is deleted.

D.

a.txt is renamed repo.

Full Access
Question # 21

Given:

A) An exception is thrown at run time.

B)

C) The compilation fails due to an error on line 2.

D) The compilation fails due to an error on line 1.

E)

F)

The compilation fails due to an error on line 3.

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

F.

Option F

Full Access
Question # 22

Given the code fragment:

You want to display the value of currency as $100.00.

Which code inserted on line 1 will accomplish this?

A.

NumberFormat formatter = NumberFormat.getInstance(locale).getCurrency();

B.

NumberFormat formatter = NumberFormat.getCurrency(locale);

C.

NumberFormat formatter = NumberFormat.getInstance(locale);

D.

NumberFormat formatter = NumberFormat.getCurrencyInstance(locale);

Full Access
Question # 23

Given:

executed using command:

java Hello “Hello World” Hello World

What is the output?

A.

An exception is thrown at runtime.

B.

Hello WorldHello World

C.

Hello World Hello World

D.

Hello WorldHelloWorld

E.

HelloHello WorldHelloWorld

Full Access
Question # 24

Given the code fragment:

What is the result?

A.

[Lettuce, Kale]

B.

A compilation error is thrown.

C.

[Lettuce, Kale]

[Seabass, Salmon]

D.

[Kale, Lettuce]

[Salmon, Seabass]

Full Access
Question # 25

Given the code fragment:

What is the result?

A.

A java.lang, UnsupportedOperationException is thrown.

B.

True

C.

False

D.

A java.lang.NullPointerException is thrown.

Full Access
Question # 26

Which two statements correctly describe capabilities of interfaces and abstract classes? (Choose two.)

A.

Interfaces cannot have protected methods but abstract classes can.

B.

Both interfaces and abstract classes can have final methods.

C.

Interfaces cannot have instance fields but abstract classes can.

D.

Interfaces cannot have static methods but abstract classes can.

E.

Interfaces cannot have methods with bodies but abstract classes can.

Full Access
Question # 27

Given:

What is the result?

A.

The compilation fails.

B.

abdf

C.

abd

D.

adf

E.

abcd

Full Access
Question # 28

Given:

What is the output?

A.

:APPLE:ORANGE:BANANA

appleorangebanana

B.

:APPLE:ORANGE:BANANA

C.

APPLE:apple ORANGE:orange BANANA:banana

D.

appleorangebanana

:APPLE:ORANGE:BANANA

E.

apple:APPLE orange:ORANGE banana:BANANA

Full Access
Question # 29

Given:

What needs to change to make these classes compile and still handle all types of Interface Worker?

A.

Replace Line 3 with public void addProcess (Worker w) {.

B.

Replace Line 1 with public class Main extends Thread {.

C.

Replace Line 2 with private List processes = new ArrayList<>();.

D.

Replace Line 3 with public void addProcess(T w) {.

Full Access
Question # 30

Given:

What is the result?

A.

6910 3

B.

10126 3

C.

3

D.

6104 3

Full Access
Question # 31

Given:

What code must you insert on Line 1 to enable the code to print Hello world?

A.

Hello.Greeting myG = new Hello.Greeting() myG.sayHi();

B.

Hello myH = new Hello();

Hello.Greeting myG = myH.new Greeting();

myG.sayHi();

C.

Hello myH = new Hello();

Hello.Greeting myG = myH.new Hello.Greeting();

myG.sayHi();

D.

Hello myH = new Hello(); Greeting myG = new Greeting(); myG.sayHi ();

Full Access
Question # 32

Given:

What is the correct definition of the JsonField annotation that makes the Point class compile?

A)

B)

C)

A.

Option A

B.

Option B

C.

Option C

Full Access
Question # 33

Given the code fragment:

var pool = Executors.newFixedThreadPool(5);

Future outcome = pool.submit(() −> 1);

Which type of lambda expression is passed into submit()?

A.

java.lang.Runnable

B.

java.util.function.Predicate

C.

java.util.function.Function

D.

java.util.concurrent.Callable

Full Access
Question # 34

Analyze the code:

Which two options can you insert inside println method to produce Global:namescope? (Choose two.)

A.

Test.prefix+Test.name

B.

new Test().prefix+new Test().name

C.

Test.prefix+Test.getName()

D.

Test.getName+prefix

E.

prefix+Test.name

F.

prefix+name

Full Access
Question # 35

Given:

Which three actions implement Java SE security guidelines? (Choose three.)

A.

Change line 7 to return names.clone();.

B.

Change line 4 to this.names = names.clone();.

C.

Change the getNames() method name to get$Names().

D.

Change line 6 to public synchronized String[] getNames() {.

E.

Change line 2 to private final String[] names;.

F.

Change line 3 to private Secret(String[] names) {.

G.

Change line 2 to protected volatile String[] names;.

Full Access
Question # 36

Given the code fragment:

What is the result?

A.

13 5 7 9

B.

1 3 5 7 9 11

C.

2 4 6 B 10

D.

2 4 6 8

Full Access
Question # 37

Given:

What is the result?

A.

It throws a runtime exception.

B.

Value of Euler = 2.71828

C.

The code does not compile.

D.

Value of Euler = “2.71828”

Full Access
Question # 38

Given:

What is the type of x?

A.

char

B.

List

C.

String

D.

List

Full Access