Pass the Oracle Java SE 1z0-819 Questions and answers with CertsForce

Viewing page 2 out of 9 pages
Viewing questions 11-20 out of questions
Questions # 11:

Which code fragment compiles?

Question # 11

Options:

A.

Option A


B.

Option B


C.

Option C


D.

Option D


Questions # 12:

Given:

Question # 12

executed using this command:

java Myclass My Car is red

What is the output of this class?

Options:

A.

Car--red--My


B.

My--Car--is


C.

My--is--java


D.

java--Myclass--My


E.

Myclass--Car--red


Questions # 13:

Given:

Question # 13

What is the result?

Options:

A.

An indexOutofBoundsException is thrown at runtime.


B.

At once 0


C.

Hat at store 4


D.

At once 1


E.

Hat at store 1


Questions # 14:

Given:

Question # 14

And the command:

java Main Helloworld

What is the result ?

Options:

A.

Input: Echo:


B.

Input: Helloworld Echo: Helloworld


C.

Input:

Then block until any input comes from System.in.


D.

Input:

Echo: Helloworld


E.

A NullPointerException is thrown at run time.


Questions # 15:

Given:

Question # 15

and omitting the throws FooException clause results in a compilation error.

Which statement is true about FooException?

Options:

A.

FooException is a subclass of RuntimeError.


B.

FooException is unchecked.


C.

The body of foo can only throw FooException.


D.

The body of foo can throw FooException or one of its subclasses.


Questions # 16:

Given:

var fruits = List.of(“apple”, “orange”, “banana”, “lemon”);

You want to examine the first element that contains the character n. Which statement will accomplish this?

Options:

A.

String result = fruits.stream().filter(f −> f.contains(“n”)).findAny();


B.

fruits.stream().filter(f −> f.contains(“n”)).forEachOrdered(System.out::print);


C.

Optional result = fruits.stream().filter(f −> f.contains (“n”)).findFirst ();


D.

Optional result = fruits.stream().anyMatch(f −> f.contains(“n”));


Questions # 17:

Given an application with a main module that has this module-info.java file:

Question # 17

Which two are true? (Choose two.)

Options:

A.

A module providing an implementation of country.CountryDetails can be compiled and added without recompiling the main module.


B.

A module providing an implementation of country.CountryDetails must have a requires main; directive in its module-info.java file.


C.

An implementation of country.countryDetails can be added to the main module.


D.

To compile without an error, the application must have at least one module in the module source path that provides an implementation of country.CountryDetails.


E.

To run without an error, the application must have at least one module in the module path that provides an implementation of country.CountryDetails.


Questions # 18:

var numbers = List.of(0,1,2,3,4,5,6,7,8,9);

You want to calculate the average of numbers. Which two codes will accomplish this? (Choose two.)

Options:

A.

double avg = numbers.stream().parallel().averagingDouble(a −> a);


B.

double avg = numbers.parallelStream().mapToInt (m −> m).average().getAsDouble ();


C.

double avg = numbers.stream().mapToInt (i −> i).average().parallel();


D.

double avg = numbers.stream().average().getAsDouble();


E.

double avg = numbers.stream().collect(Collectors.averagingDouble(n −> n));


Questions # 19:

Which code fragment added to line 1 enables the code to compile and print Hello Joe?

A)

Question # 19

B)

Question # 19

C)

Question # 19

D)

Question # 19


Questions # 20:

Given the code fragment:

Question # 20

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

Which code inserted on line 1 will accomplish this?

Options:

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);


Viewing page 2 out of 9 pages
Viewing questions 11-20 out of questions