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

Viewing page 1 out of 7 pages
Viewing questions 1-10 out of questions
Questions # 1:

Given the content of /resourses/Message.properties:

welcome1=”Good day!”

and given the code fragment:

Properties prop = new Properties ();

FileInputStream fis = new FileInputStream (“/resources/Message.properties”);

prop.load(fis);

System.out.println(prop.getProperty(“welcome1”));

System.out.println(prop.getProperty(“welcome2”, “Test”));//line n1

System.out.println(prop.getProperty(“welcome3”));

What is the result?

Options:

A.

Good day!Testfollowed by an Exception stack trace


B.

Good day!followed by an Exception stack trace


C.

Good day!Testnull


D.

A compilation error occurs at line n1.


Expert Solution
Questions # 2:

Which class definition compiles?

Options:

A.

B.

C.

D.

Expert Solution
Questions # 3:

Given the code fragment:

List str = Arrays.asList (“my”, “pen”, “is”, “your’, “pen”);

Predicate test = s -> {

int i = 0;

boolean result = s.contains (“pen”);

System.out.print(i++) + “:”);

return result;

};

str.stream()

.filter(test)

.findFirst()

.ifPresent(System.out ::print);

What is the result?

Options:

A.

0 : 0 : pen


B.

0 : 1 : pen


C.

0 : 0 : 0 : 0 : 0 : pen


D.

0 : 1 : 2 : 3 : 4 :


E.

A compilation error occurs.


Expert Solution
Questions # 4:

Given:

Question # 4

What is the result?

Options:

A.

Bar HelloFoo Hello


B.

Bar HelloBaz Hello


C.

Baz Hello


D.

A compilation error occurs in the Daze class.


Expert Solution
Questions # 5:

Given:

Question # 5

and the code fragment:

Question # 5

What is the result?

Options:

A.

truetrue


B.

falsetrue


C.

falsefalse


D.

truefalse


Expert Solution
Questions # 6:

Given the code fragment:

Question # 6

What is the result?

Options:

A.

A compilation error occurs at line n1.


B.

A compilation error occurs at line n2.


C.

The code reads the password without echoing characters on the console.


D.

A compilation error occurs because the IOException isn’t declared to be thrown or caught?


Expert Solution
Questions # 7:

Given:

Question # 7

and

Question # 7

Which interface from the java.util.function package should you use to refactor the class Txt?

Options:

A.

Consumer


B.

Predicate


C.

Supplier


D.

Function


Expert Solution
Questions # 8:

Given the code fragment:

List listVal = Arrays.asList(“Joe”, “Paul”, “Alice”, “Tom”);

System.out.println (

// line n1

);

Which code fragment, when inserted at line n1, enables the code to print the count of string elements whose length is greater than three?

Options:

A.

listVal.stream().filter(x -> x.length()>3).count()


B.

listVal.stream().map(x -> x.length()>3).count()


C.

listVal.stream().peek(x -> x.length()>3).count().get()


D.

listVal.stream().filter(x -> x.length()>3).mapToInt(x -> x).count()


Expert Solution
Questions # 9:

Given the code fragment:

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

BufferedReader br = new BufferedReader (new InputStremReader (System.in));

System.out.print (“Enter GDP: “);

//line 1

}

Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?

Options:

A.

int GDP = Integer.parseInt (br.readline());


B.

int GDP = br.read();


C.

int GDP = br.nextInt();


D.

int GDP = Integer.parseInt (br.next());


Expert Solution
Questions # 10:

Which two statements are true about synchronization and locks? (Choose two.)

Options:

A.

A thread automatically acquires the intrinsic lock on a synchronized statement when executed.


B.

The intrinsic lock will be retained by a thread if return from a synchronized method is caused by an uncaught exception.


C.

A thread exclusively owns the intrinsic lock of an object between the time it acquires the lock and the time it releases it.


D.

A thread automatically acquires the intrinsic lock on a synchronized method’s object when entering that method.


E.

Threads cannot acquire intrinsic locks on classes.


Expert Solution
Viewing page 1 out of 7 pages
Viewing questions 1-10 out of questions