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

Viewing page 5 out of 7 pages
Viewing questions 41-50 out of questions
Questions # 41:

Given the code fragment:

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

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

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

Path res1 = path2.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
Questions # 42:

Which statement is true about the DriverManager class?

Options:

A.

It returns an instance of Connection.


B.

It executes SQL statements against the database.


C.

It only queries metadata of the database.


D.

it is written by different vendors for their specific database.


Expert Solution
Questions # 43:

Given the code fragment:

Question # 43

What is the result?

Options:

A.

A compilation error occurs at line n1.


B.

courseJava


C.

Javacourse


D.

A compilation error occurs at line n2.


Expert Solution
Questions # 44:

Given:

class Worker extends Thread {

CyclicBarrier cb;

public Worker(CyclicBarrier cb) { this.cb = cb; }

public void run () {

try {

cb.await();

System.out.println(“Worker…”);

} catch (Exception ex) { }

}

}

class Master implements Runnable { //line n1

public void run () {

System.out.println(“Master…”);

}

}

and the code fragment:

Master master = new Master();

//line n2

Worker worker = new Worker(cb);

worker.start();

You have been asked to ensure that the run methods of both the Worker and Master classes are executed.

Which modification meets the requirement?

Options:

A.

At line n2, insert CyclicBarrier cb = new CyclicBarrier(2, master);


B.

Replace line n1 with class Master extends Thread {


C.

At line n2, insert CyclicBarrier cb = new CyclicBarrier(1, master);


D.

At line n2, insert CyclicBarrier cb = new CyclicBarrier(master);


Expert Solution
Questions # 45:

Given the code fragment:

Map books = new TreeMap<>();

books.put (1007, “A”);

books.put (1002, “C”);

books.put (1003, “B”);

books.put (1003, “B”);

System.out.println (books);

What is the result?

Options:

A.

{1007=A, 1003=B, 1002=C}


B.

{1007=A, 1003=B, 1003=B, 1002=C}


C.

{1007=A, 1002=C, 1003=B, 1003=B}


D.

{1002=C, 1003=B, 1007=A}


Expert Solution
Questions # 46:

For which three objects must a vendor provide implementations in its JDBC driver? (Choose three.)

Options:

A.

Time


B.

Date


C.

Statement


D.

ResultSet


E.

Connection


F.

SQLException


G.

DriverManager


Expert Solution
Questions # 47:

Given:

class Vehicle {

int vno;

String name;

public Vehicle (int vno, String name) {

this.vno = vno,;

this.name = name;

}

public String toString () {

return vno + “:” + name;

}

}

and this code fragment:

Set vehicles = new TreeSet <> ();

vehicles.add(new Vehicle (10123, “Ford”));

vehicles.add(new Vehicle (10124, “BMW”));

System.out.println(vehicles);

What is the result?

Options:

A.

10123 Ford10124 BMW


B.

10124 BMW10123 Ford


C.

A compilation error occurs.


D.

A ClassCastException is thrown at run time.


Expert Solution
Questions # 48:

Given the code fragment:

Path file = Paths.get (“courses.txt”);

// line n1

Assume the courses.txt is accessible.

Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?

Options:

A.

List fc = Files.list(file);fc.stream().forEach (s -> System.out.println(s));


B.

Stream fc = Files.readAllLines (file);fc.forEach (s - > System.out.println(s));


C.

List fc = Files.readAllLines(file);fc.stream().forEach (s -> System.out.println(s));


D.

Stream fc = Files.list (file);fc.forEach (s -> System.out.println(s));


Expert Solution
Questions # 49:

Given the code fragments:

class Caller implements Callable {

String str;

public Caller (String s) {this.str=s;}

public String call()throws Exception { return str.concat (“Caller”);}

}

class Runner implements Runnable {

String str;

public Runner (String s) {this.str=s;}

public void run () { System.out.println (str.concat (“Runner”));}

}

and

public static void main (String[] args) throws InterruptedException, ExecutionException {

ExecutorService es = Executors.newFixedThreadPool(2);

Future f1 = es.submit (new Caller (“Call”));

Future f2 = es.submit (new Runner (“Run”));

String str1 = (String) f1.get();

String str2 = (String) f2.get();//line n1

System.out.println(str1+ “:” + str2);

}

What is the result?

Options:

A.

The program prints:Run RunnerCall Caller : nullAnd the program does not terminate.


B.

The program terminates after printing:Run RunnerCall Caller : Run


C.

A compilation error occurs at line n1.


D.

An Execution is thrown at run time.


Expert Solution
Questions # 50:

Given the code fragment:

BiFunction val = (t1, t2) -> t1 + t2;//line n1

System.out.println(val.apply(10, 10.5));

What is the result?

Options:

A.

20


B.

20.5


C.

A compilation error occurs at line n1.


D.

A compilation error occurs at line n2.


Expert Solution
Viewing page 5 out of 7 pages
Viewing questions 41-50 out of questions