aiotestking uk

1Z0-809 Exam Questions - Online Test


1Z0-809 Premium VCE File

Learn More 100% Pass Guarantee - Dumps Verified - Instant Download
150 Lectures, 20 Hours

Q1. public class ForTest { 

public static void main(String[] args) { 

int[] arrar = {1,2,3}; 

for ( foo ) { 

Which three are valid replacements for foo so that the program will compiled and run? 

A. int i: array 

B. int i = 0; i < 1; i++ 

C. ;; 

D. ; i < 1; i++ 

E. ; i < 1; 

Answer: A,B,C 

Q2. Given: 

class Book { 

int id; 

String name; 

public Book (int id, String name) { 

this.id = id; 

this.name = name; 

public boolean equals (Object obj) { //line n1 

boolean output = false; 

Book b = (Book) obj; 

if (this.name.equals(b name))} 

output = true; 

return output; 

and the code fragment: 

Book b1 = new Book (101, “Java Programing”); 

Book b2 = new Book (102, “Java Programing”); 

System.out.println (b1.equals(b2)); //line n2 

Which statement is true? 

A. The program prints true. 

B. The program prints false. 

C. A compilation error occurs. To ensure successful compilation, replace line n1 with: boolean equals (Book obj) { 

D. A compilation error occurs. To ensure successful compilation, replace line n2 with: System.out.println (b1.equals((Object) b2)); 

Answer:

Q3. Given: 

What is the result? 

A. Red 0 Orange 0 Green 3 

B. Red 0 Orange 0 Green 6 

C. Red 0 Orange 1 

D. Green 4 

E. Compilation fails 

Answer:

Q4. Given: 

What is the result? 

A. Good Day! Good Luck! 

B. Good Day! Good Day! 

C. Good Luck! Good Day! 

D. Good Luck! Good Luck! 

E. Compilation fails 

Answer:

Q5. 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:

Q6. Given the content of /resourses/Message.properties: 

welcome1=”Good day!” 

and given the code fragment: 

Properties prop = new Properties (); 

FileInputStream fis = new FileInputStream (“/resources/Message.properties”); 

prop.load(fis); 

System.out.println(prop.getProperty(“welcome1”)); 

System.out.println(prop.getProperty(“welcome2”, “Test”));//line n1 

System.out.println(prop.getProperty(“welcome3”)); 

What is the result? 

A. Good day! 

Test 

followed by an Exception stack trace 

B. Good day! 

followed by an Exception stack trace 

C. Good day! 

Test 

null 

D. A compilation error occurs at line n1. 

Answer:

Q7. Given the for loop construct: 

for ( expr1 ; expr2 ; expr3 ) { 

statement; 

Which two statements are true? 

A. This is not the only valid for loop construct; there exits another form of for loop constructor. 

B. The expression expr1 is optional. it initializes the loop and is evaluated once, as the loop begin. 

C. When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration through the loop. 

D. The expression expr3 must be present. It is evaluated after each iteration through the loop. 

Answer: B,C 

Explanation: 

The for statement have this forms: 

for (init-stmt; condition; next-stmt) { 

body 

There are three clauses in the for statement. 

The init-stmt statement is done before the loop is started, usually to initialize an iteration 

variable. 

The condition expression is tested before each time the loop is done. The loop isn't 

executed if the boolean expression is false (the same as the while loop). 

The next-stmt statement is done after the body is executed. It typically increments an 

iteration variable. 

Q8. Which two reasons should you use interfaces instead of abstract classes? 

A. You expect that classes that implement your interfaces have many common methods or fields, or require access modifiers other than public. 

B. You expect that unrelated classes would implement your interfaces. 

C. You want to share code among several closely related classes. 

D. You want to declare non-static on non-final fields. 

E. You want to take advantage of multiple inheritance of type. 

Answer: A,E 

Reference: http://www.programmerinterview.com/index.php/java-questions/interface-vs-abstract-class/ 

Q9. Given: 

What is the result? 

A. 2 4 6 8 

B. 2 4 6 8 9 

C. 1 3 5 7 

D. 1 3 5 7 9 

Answer:

Q10. A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the results? 

A. Compilation fails. 

B. The third argument is given the value null. 

C. The third argument is given the value void. 

D. The third argument is given the value zero. 

E. The third argument is given the appropriate falsy value for its declared type. F) An exception occurs when the method attempts to access the third argument. 

Answer: