1Z0-803 Exam - Java SE 7 Programmer I

certleader.com

Q1. Which three are bad practices? 

A. Checking for ArrayIndexoutofBoundsException when iterating through an array to determine when all elements have been visited 

B. Checking for Error and. If necessary, restarting the program to ensure that users are unaware problems 

C. Checking for FileNotFoundException to inform a user that a filename entered is not valid 

D. Checking for ArrayIndexoutofBoundsException and ensuring that the program can recover if one occur 

E. Checking for an IOException and ensuring that the program can recover if one occurs 

Answer: ABD 

Q2. Given: 

What is the result? 

A. The sum is 2 

B. The sum is 14 

C. The sum is 15 

D. The loop executes infinite times 

E. Compilation fails 

Answer:

Q3. What is the result? 

A. 6 7 8 

B. 7 8 9 

C. 0 1 2 

D. 6 8 10 

E. Compilation fails 

Answer:

Q4. Given the code fragment: 

System.out.printIn("Result: " + 2 + 3 + 5); 

System.out.printIn("Result: " + 2 + 3 * 5); 

What is the result? 

A. Result: 10 

Result: 30 

Result: 10 

Result: 25 

C. Result: 235 

Result: 215 

D. Result: 215 

Result: 215 

E. Compilation fails 

Answer:

Q5. Given: 

 

Which two actions, used independently, will permit this class to compile? 

A. Adding throws IOException to the main() method signature 

B. Adding throws IOException to the doSoomething() method signature 

C. Adding throws IOException to the main() method signature and to the dosomething() method 

D. Adding throws IOException to the dosomething() method signature and changing the catch argument to IOException 

E. Adding throws IOException to the main() method signature and changing the catch argument to IOException 

Answer: CD 

Q6. Given: 

Which statement, when inserted into line 5, is valid change? 

A. asc = sc; 

B. sc = asc; 

C. asc = (object) sc; 

D. asc = sc.clone () 

Answer:

Q7. Given: 

What is the reference type of myZ and what is the type of the object it references? 

A. Reference type is Z; object type is Z. 

B. Reference type is Y; object type is Y. 

C. Reference type is Z; object type is Y. 

D. Reference type is X; object type is Z. 

Answer:

Q8. What is the result? 

A. Valid 

B. Not valid 

C. Compilation fails 

D. An IllegalArgumentException is thrown at run time 

Answer:

Q9. Given: 

What three modifications are necessary to ensure that the class is being properly encapsulated? 

This class is poorly encapsulated. You need to change the circle class to compute and return the area instead. 

A. Change the access modifier of the setradius () method to private 

B. Change the getArea () method public double getArea () { return area; } 

C. When the radius is set in the Circle constructor and the setRadius () method, recomputed the area and store it into the area field 

D. Change the getRadius () method: 

public double getRadius () { 

area = Math.PI * radius * radius; 

return radius; 

Answer: BCD 

Q10. Given: 

Which code fragment, when inserted at line 14, enables the code to print Mike Found? 

A. int f = ps.indexOf {new patient (“Mike”)}; 

B. int f = ps.indexOf (patient(“Mike”)); 

C. patient p = new Patient (“Mike”); 

int f = pas.indexOf(P) 

D. int f = ps.indexOf(p2); 

Answer: