1Z0-809 Exam - Java SE 8 Programmer II

certleader.com

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

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

Q3. Which three statements are benefits of encapsulation? 

A. Allows a class implementation to change without changing t he clients 

B. Protects confidential data from leaking out of the objects 

C. Prevents code from causing exceptions 

D. Enables the class implementation to protect its invariants 

E. Permits classes to be combined into the same package 

F. Enables multiple instances of the same class to be created safely 

Answer: A,B,D 

Q4. Given: 

1. 

abstract class Shape { 

2. 

Shape ( ) { System.out.println (“Shape”); } 

3. 

protected void area ( ) { System.out.println (“Shape”); } 

4. 

5. 

6. 

class Square extends Shape { 

7. 

int side; 

8. 

Square int side { 9./* insert code here */ 

10. 

this.side = side; 

11. 

12. 

public void area ( ) { System.out.println (“Square”); } 

13. 

14. 

class Rectangle extends Square { 

15. 

int len, br; 

16. 

Rectangle (int x, int y) { 

17. 

/* insert code here */ 

18. 

len = x, br = y; 

19. 

20. 

void area ( ) { System.out.println (“Rectangle”); } 

21. 

Which two modifications enable the code to compile? 

A. At line 1, remove abstract 

B. At line 9, insert super ( ); 

C. At line 12, remove public 

D. At line 17, insert super (x); 

E. At line 17, insert super (); super.side = x; 

F. At line 20, use public void area ( ) { 

Answer: C,D 

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

Q6. Which two are Java Exception classes? 

A. SercurityException 

B. DuplicatePathException 

C. IllegalArgumentException 

D. TooManyArgumentsException 

Answer: A,C 

Q7. Which statement is true about the DriverManager class? 

A. It returns an instance of Connection. 

B. it executes SQL statements against the database. 

C. It only queries metadata of the database. 

D. it is written by different vendors for their specific database. 

Answer:

Explanation: The DriverManager returns an instance of Doctrine\DBAL\Connection which is a wrapper around the underlying driver connection (which is often a PDO instance). Reference: http://doctrine-dbal.readthedocs.org/en/latest/reference/configuration.html 

Q8. Given the code fragment: 

List<Integer> values = Arrays.asList (1, 2, 3); 

values.stream () 

.map(n -> n*2)//line n1 

.peek(System.out::print)//line n2 

.count(); 

What is the result? 

A. 246 

B. The code produces no output. 

C. A compilation error occurs at line n1. 

D. A compilation error occurs at line n2. 

Answer:

Q9. Given: What is the result? 

A. 0 Done 

B. First Exception Done 

C. Second Exception 

D. Done Third Exception 

E. Third Exception 

Answer:

Q10. For which three objects must a vendor provide implementations in its JDBC driver? 

A. Time B. Date 

C. Statement 

D. ResultSet 

E. Connection 

F. SQLException 

G. DriverManager 

Answer: C,D,E 

Explanation: Database vendors support JDBC through the JDBC driver interface or through the ODBC connection. Each driver must provide implementations of java.sql.Connection, java.sql.Statement, java.sql.PreparedStatement, java.sql.CallableStatement, and java.sql.Re sultSet. They must also implement the java.sql.Driver interface for use by the generic java.sql.DriverManager interface.