Weekend Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmas50

Oracle 1z0-809 - Java SE 8 Programmer II

Page: 4 / 6
Total 196 questions

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?

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.

Given:

public class Canvas implements Drawable {

public void draw () { }

}

public abstract class Board extends Canvas { }

public class Paper extends Canvas {

protected void draw (int color) { }

}

public class Frame extends Canvas implements Drawable {

public void resize () { }

abstract void open ();

}

public interface Drawable {

public abstract void draw ();

}

Which statement is true?

A.

Board does not compile.

B.

Paper does not compile.

C.

Frame does not compile.

D.

Drawable does not compile.

E.

All classes compile successfully.

Given:

and the code fragment:

Which definition of the ColorSorter class sorts the blocks list?

A.

B.

C.

D.

What is true about the java.sql.Statement interface?

A.

It provides a session with the database.

B.

It is used to get an instance of a Connection object by using JDBC drivers.

C.

It provides a cursor to fetch the resulting data.

D.

It provides a class for executing SQL statements and returning the results.

Given the code fragment:

What is the result?

A.

[X][X, X][X, X, X][X, X, X, X]

B.

[X, X]

C.

[X][X, X][X, X, X]

D.

[X, X][X, X, X, X]

Given the code fragment:

public void recDelete (String dirName) throws IOException {

File [ ] listOfFiles = new File (dirName) .listFiles();

if (listOfFiles ! = null && listOfFiles.length >0) {

for (File aFile : listOfFiles) {

if (!aFile.isDirectory ()) {

if (aFile.getName ().endsWith (“.class”))

aFile.delete ();

}

}

}

}

Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.

What is the result?

A.

The method deletes all the .class files in the Projects directory and its subdirectories.

B.

The method deletes the .class files of the Projects directory only.

C.

The method executes and does not make any changes to the Projects directory.

D.

The method throws an IOException.

Given the code fragment:

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

//line n2

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

What is the result?

A.

20

B.

20.5

C.

A compilation error occurs at line n1.

D.

A compilation error occurs at line n2.

Given:

and this code fragment:

What is the result?

A.

Open-Close–Exception – 1Open–Close–

B.

Open–Close–Open–Close–

C.

A compilation error occurs at line n1.

D.

Open–Close–Open–

Given the code fragment:

String str = “Java is a programming language”;

ToIntFunction indexVal = str: : indexOf; //line n1

int x = indexVal.applyAsInt(“Java”);//line n2

System.out.println(x);

What is the result?

A.

0

B.

1

C.

A compilation error occurs at line n1.

D.

A compilation error occurs at line n2.

What is the result?

A.

A compilation error occurs at line 7.

B.

100

C.

A compilation error occurs at line 8.

D.

A compilation error occurs at line 15.