1Z0-809 | The Up to the minute Guide To 1Z0-809 exam question


Q11. Which two statements are true for a two-dimensional array? 

A. It is implemented as an array of the specified element type. 

B. Using a row by column convention, each row of a two-dimensional array must be of the same size. 

C. At declaration time, the number of elements of the array in each dimension must be specified. 

D. All methods of the class Object may be invoked on the two-dimensional array. 

Answer: A,D 

Q12. Given: 

public class MainMethod { 

void main() { 

System.out.println("one"); 

static void main(String args) { 

System.out.println("two"); 

public static void main(String[] args) { 

System.out.println("three"); 

void mina(Object[] args) { 

System.out.println("four"); 

What is printed out when the program is excuted? 

A. one 

B. two 

C. three 

D. four 

Answer:

Q13. Which two statements are true about localizing an application? 

A. Support for new regional languages does not require recompilation of the code. 

B. Textual elements (messages and GUI labels) are hard-coded in the code. 

C. Language and region-specific programs are created using localized data. 

D. Resource bundle files include data and currency information. 

E. Language codes use lowercase letters and region codes use uppercase letters. 

Answer: A,E 

Reference: http://docs.oracle.com/javase/7/docs/technotes/guides/intl/ 

Q14. Given: 

IntStream stream = IntStream.of (1,2,3); IntFunction<Integer> inFu= x -> y -> x*y;//line n1 IntStream newStream = stream.map(inFu.apply(10));//line n2 

newStream.forEach(System.output::print); 

Which modification enables the code fragment to compile? 

A. Replace line n1 with: 

IntFunction<UnaryOperator> inFu = x -> y -> x*y; 

B. Replace line n1 with: 

IntFunction<IntUnaryOperator> inFu = x -> y -> x*y; 

C. Replace line n1 with: 

BiFunction<IntUnaryOperator> inFu = x -> y -> x*y; 

D. Replace line n2 with: 

IntStream newStream = stream.map(inFu.applyAsInt (10)); 

Answer:

Q15. You want to create a singleton class by using the Singleton design pattern. Which two statements enforce the singleton nature of the design? 

A. Make the class static. 

B. Make the constructor private. 

C. Override equals() and hashCode() methods of the java.lang.Object class. 

D. Use a static reference to point to the single instance. 

E. Implement the Serializable interface. 

Answer: A,B 

Q16. Given the code fragments: 

class MyThread implements Runnable { 

private static AtomicInteger count = new AtomicInteger (0); 

public void run () { 

int x = count.incrementAndGet(); 

System.out.print (x+” “); 

and 

Thread thread1 = new Thread(new MyThread()); 

Thread thread2 = new Thread(new MyThread()); 

Thread thread3 = new Thread(new MyThread()); 

Thread [] ta = {thread1, thread2, thread3}; 

for (int x= 0; x < 3; x++) { 

ta[x].start(); 

Which statement is true? 

A. The program prints 1 2 3 and the order is unpredictable. 

B. The program prints 1 2 3. 

C. The program prints 1 1 1. 

D. A compilation error occurs. 

Answer:

Q17. Given the code fragment: 

class CallerThread implements Callable<String> { 

String str; 

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

public String call() throws Exception { 

return str.concat(“Call”); 

and 

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

ExecutorService es = Executors.newFixedThreadPool(4); //line n1 

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

String str = f1.get().toString(); 

System.out.println(str); 

Which statement is true? 

A. The program prints Call Call and terminates. 

B. The program prints Call Call and does not terminate. 

C. A compilation error occurs at line n1. 

D. An ExecutionException is thrown at run time. 

Answer:

Q18. Given the code fragment: 

List<String> colors = Arrays.asList(“red”, “green”, “yellow”); 

Predicate<String> test = n - > { 

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

return n.contains(“red”); 

}; 

colors.stream() 

.filter(c -> c.length() > 3) 

.allMatch(test); 

What is the result? 

A. Searching… 

B. Searching… Searching… 

C. Searching… Searching… Searching… 

D. A compilation error occurs. 

Answer:

Q19. 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? 

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); 

Answer:

Q20. Given: What is the result? 

A. box 

B. nbo 

C. bo 

D. nb 

E. An exception is thrown at runtime 

Answer: