Act now and download your Oracle 1Z0-809 test today! Do not waste time for the worthless Oracle 1Z0-809 tutorials. Download Refresh Oracle Java SE 8 Programmer II exam with real questions and answers and begin to learn Oracle 1Z0-809 with a classic professional.

Q9. Which two items can legally be contained within a java class declaration? 

A. An import statement 

B. A field declaration 

C. A package declaration 

D. A method declaration 

Answer: B,D 

Reference: 

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html 


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


Q11. Given: 

class UserException extends Exception { } 

class AgeOutOfLimitException extends UserException { } 

and the code fragment: 

class App { 

public void doRegister(String name, int age) 

throws UserException, AgeOutOfLimitException { 

if (name.length () < 6) { 

throw new UserException (); 

} else if (age >= 60) { 

throw new AgeOutOfLimitException (); 

} else { 

System.out.println(“User is registered.”); 

public static void main(String[ ] args) throws UserException { 

App t = new App (); 

t.doRegister(“Mathew”, 60); 

What is the result? 

A. User is registered. 

B. An AgeOutOfLimitException is thrown. 

C. A UserException is thrown. 

D. A compilation error occurs in the main method. 

Answer:


Q12. Given the code fragments: 

public class Book implements Comparator<Book> { 

String name; 

double price; 

public Book () {} 

public Book(String name, double price) { 

this.name = name; 

this.price = price; 

public int compare(Book b1, Book b2) { 

return b1.name.compareTo(b2.name); 

public String toString() { 

return name + “:” + price; 

and 

List<Book>books = Arrays.asList (new Book (“Beginning with Java”, 2), new book (“A 

Guide to Java Tour”, 3)); 

Collections.sort(books, new Book()); 

System.out.print(books); 

What is the result? 

A. [A Guide to Java Tour:3, Beginning with Java:2] 

B. [Beginning with Java:2, A Guide to Java Tour:3] 

C. A compilation error occurs because the Book class does not override the abstract method compareTo(). 

D. An Exception is thrown at run time. 

Answer:


Q13. Given the code fragment: 

Path path1 = Paths.get(“/app/./sys/”); 

Path res1 = path1.resolve(“log”); 

Path path2 = Paths.get(“/server/exe/”); 

Path res1 = path1.resolve(“/readme/”); 

System.out.println(res1); 

System.out.println(res2); 

What is the result? 

A. /app/sys/log /readme/server/exe 

B. /app/log/sys /server/exe/readme 

C. /app/./sys/log /readme 

D. /app/./sys/log /server/exe/readme 

Answer:


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


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


Q16. Given the code fragment: 

9. 

Connection conn = DriveManager.getConnection(dbURL, userName, passWord); 

10. 

String query = “SELECT id FROM Employee”; 

11. 

try (Statement stmt = conn.createStatement()) { 

12. 

ResultSet rs = stmt.executeQuery(query); 13.stmt.executeQuery(“SELECT id FROM Customer”); 

14. 

while (rs.next()) { 

15. 

//process the results 16.System.out.println(“Employee ID: “+ rs.getInt(“id”)); 17.} 

18. 

} catch (Exception e) { 

19. 

System.out.println (“Error”); 

20. 

Assume that: 

The required database driver is configured in the classpath. 

The appropriate database is accessible with the dbURL, userName, and passWord exists. 

The Employee and Customer tables are available and each table has id column with a few 

records and the SQL queries are valid. 

What is the result of compiling and executing this code fragment? 

A. The program prints employee IDs. 

B. The program prints customer IDs. 

C. The program prints Error. 

D. compilation fails on line 13. 

Answer: