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

Viewing page 3 out of 7 pages
Viewing questions 21-30 out of questions
Questions # 21:

Which statement is true about java.time.Duration?

Options:

A.

It tracks time zones.


B.

It preserves daylight saving time.


C.

It defines time-based values.


D.

It defines date-based values.


Expert Solution
Questions # 22:

Which action can be used to load a database driver by using JDBC3.0?

Options:

A.

Add the driver class to the META-INF/services folder of the JAR file.


B.

Include the JDBC driver class in a jdbc.properties file.


C.

Use the java.lang.Class.forName method to load the driver class.


D.

Use the DriverManager.getDriver method to load the driver class.


Expert Solution
Questions # 23:

Given the code fragment:

List list1 = Arrays.asList(10, 20);

List list2 = Arrays.asList(15, 30);

//line n1

Which code fragment, when inserted at line n1, prints 10 20 15 30?

Options:

A.

Stream.of(list1, list2).flatMap(list -> list.stream()).forEach(s -> System.out.print(s + “ “));


B.

Stream.of(list1, list2).flatMap(list -> list.intStream()).forEach(s -> System.out.print(s + “ “));


C.

list1.stream().flatMap(list2.stream().flatMap(e1 -> e1.stream()).forEach(s -> System.out.println(s + “ “));


D.

Stream.of(list1, list2).flatMapToInt(list -> list.stream()).forEach(s -> System.out.print(s + “ “));


Expert Solution
Questions # 24:

Given:

Question # 24

and the code fragment:

Question # 24

What is the result?

Options:

A.

[Java EE: Helen:Houston][Java ME: Jessy:Chicago, Java ME: Mark:Chicago]


B.

Java EEJava ME


C.

[Java ME: Jessy:Chicago, Java ME: Mark:Chicago][Java EE: Helen:Houston]


D.

A compilation error occurs.


Expert Solution
Questions # 25:

Given:

class CheckClass {

public static int checkValue (String s1, String s2) {

return s1 length() – s2.length();

}

}

and the code fragment:

String[] strArray = new String [] {“Tiger”, “Rat”, “Cat”, “Lion”}

//line n1

for (String s : strArray) {

System.out.print (s + “ “);

}

Which code fragment should be inserted at line n1 to enable the code to print Rat Cat Lion Tiger?

Options:

A.

Arrays.sort(strArray, CheckClass : : checkValue);


B.

Arrays.sort(strArray, (CheckClass : : new) : : checkValue);


C.

Arrays.sort(strArray, (CheckClass : : new).checkValue);


D.

Arrays.sort(strArray, CheckClass : : new : : checkValue);


Expert Solution
Questions # 26:

Given the code fragment:

Question # 26

Which should be inserted into line n1 to print Average = 2.5?

Options:

A.

IntStream str = Stream.of (1, 2, 3, 4);


B.

IntStream str = IntStream.of (1, 2, 3, 4);


C.

DoubleStream str = Stream.of (1.0, 2.0, 3.0, 4.0);


D.

Stream str = Stream.of (1, 2, 3, 4);


Expert Solution
Questions # 27:

Given:

interface Rideable {Car getCar (String name); }

class Car {

private String name;

public Car (String name) {

this.name = name;

}

}

Which code fragment creates an instance of Car?

Options:

A.

Car auto = Car (“MyCar”): : new;


B.

Car auto = Car : : new;Car vehicle = auto : : getCar(“MyCar”);


C.

Rideable rider = Car : : new;Car vehicle = rider.getCar(“MyCar”);


D.

Car vehicle = Rideable : : new : : getCar(“MyCar”);


Expert Solution
Questions # 28:

Given:

Question # 28

and the code fragment:

Question # 28

The threads t1 and t2 execute asynchronously and possibly prints ABCA or AACB.

You have been asked to modify the code to make the threads execute synchronously and prints ABC.

Which modification meets the requirement?

Options:

A.

start the threads t1 and t2 within a synchronized block.


B.

Replace line n1 with:private synchronized int count = 0;


C.

Replace line n2 with:public synchronized void run () {


D.

Replace line n2 with:volatile int count = 0;


Expert Solution
Questions # 29:

Given the content:

Question # 29

and given the code fragment:

Question # 29

Which two code fragments, when inserted at line 1 independently, enable the code to print “Wie geht’s?”

Options:

A.

currentLocale = new Locale (“de”, “DE”);


B.

currentLocale = new Locale.Builder ().setLanguage (“de”).setRegion (“DE”).build();


C.

currentLocale = Locale.GERMAN;


D.

currentlocale = new Locale();currentLocale.setLanguage (“de”);currentLocale.setRegion (“DE”);


E.

currentLocale = Locale.getInstance(Locale.GERMAN,Locale.GERMANY);


Expert Solution
Questions # 30:

Given the code fragment:

Path path1 = Paths.get(“/app/./sys/”);

Path res1 = path1.resolve(“log”);

Path path2 = Paths.get(“/server/exe/”);

Path res1 = path1.resolve(“/readme/”);

System.out.println(res1);

System.out.println(res2);

What is the result?

Options:

A.

/app/sys/log/readme/server/exe


B.

/app/log/sys/server/exe/readme


C.

/app/./sys/log/readme


D.

/app/./sys/log/server/exe/readme


Expert Solution
Viewing page 3 out of 7 pages
Viewing questions 21-30 out of questions