You want to create a singleton class by using the Singleton design pattern. Which two statements enforce the singleton nature of the design? (Choose two.)
Correct Answer:BD
Given the code fragment:
Which modification enables the code to print Price 5 New Price 4?
Correct Answer:A
Given:
and the command: java Product 0 What is the result?
Correct Answer:D
You have been asked to create a ResourceBundle which uses a properties file to localize an application. Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?
Correct Answer:D
Given the code fragment:
What is the result?
Correct Answer:A
Given the code fragments:
class Caller implements Callable
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) 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?
Correct Answer:A