Oracle 1z0-809 - Java SE 8 Programmer II
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?
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?
Given:
and the code fragment:
Which definition of the ColorSorter class sorts the blocks list?
What is true about the java.sql.Statement interface?
Given the code fragment:
What is the result?
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?
Given the code fragment:
BiFunction
//line n2
System.out.println(val.apply(10, 10.5));
What is the result?
Given:
and this code fragment:
What is the result?
Given the code fragment:
String str = “Java is a programming languageâ€;
ToIntFunction
int x = indexVal.applyAsInt(“Javaâ€);//line n2
System.out.println(x);
What is the result?
What is the result?