1Z0-803 Exam - Java SE 7 Programmer I

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:

A. Values are : [EE, ME] 

B. Values are : [EE, EE, ME] 

C. Values are : [EE, ME, EE] 

D. Values are : [SE, EE, ME, EE] 

E. Values are : [EE, ME, SE, EE] 

Answer:

Q3. View the Exhibit. 

public class Hat { 

public int ID =0; 

public String name = "hat"; 

public String size = "One Size Fit All"; 

public String color=""; 

public String getName() { return name; } 

public void setName(String name) { 

this.name = name; 

Given 

public class TestHat { 

public static void main(String[] args) { 

Hat blackCowboyHat = new Hat(); 

Which statement sets the name of the Hat instance? 

A. blackCowboyHat.setName = "Cowboy Hat"; 

B. setName("Cowboy Hat"); 

C. Hat.setName("Cowboy Hat"); 

D. blackCowboyHat.setName("Cowboy Hat"); 

Answer:

Q4. Given the code fragments: 

What is the result? 

A. Super 

Sub 

Sub 

B. Contract 

Contract 

Super 

C. Compilation fails at line n1 

D. Compilation fails at line n2 

Answer:

Q5. Which code fragment is illegal? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

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

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 false value for its declared type. 

F. An exception occurs when the method attempts to access the third argument. 

Answer:

Q7. Given: 

public class Main { 

public static void main(String[] args) { 

try { 

doSomething(); 

catch (SpecialException e) { 

System.out.println(e); 

}} 

static void doSomething() { 

int [] ages = new int[4]; 

ages[4] = 17; 

doSomethingElse(); 

static void doSomethingElse() { 

throw new SpecialException("Thrown at end of doSomething() method"); } 

What is the output? 

A. SpecialException: Thrown at end of doSomething() method 

B. Error in thread "main" java.lang. 

ArrayIndexOutOfBoundseror 

C. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 

at Main.doSomething(Main.java:12) 

at Main.main(Main.java:4) 

D. SpecialException: Thrown at end of doSomething() method at 

Main.doSomethingElse(Main.java:16) 

at Main.doSomething(Main.java:13) 

at Main.main(Main.java:4) 

Answer:

Q8. Given: 

How many objects have been created when the line / / do complex stuff is reached? 

A. Two 

B. Three 

C. Four 

D. Six 

Answer:

Q9. Given the class definitions: 

And the code fragment of the main() method, 

What is the result? 

A. Java 

Java 

Java 

B. Java 

Jeve 

va 

C. Java 

Jeve 

ve 

D. Compilation fails 

Answer:

Q10. Given: 

Given the for loop construct: 

Which constructor initializes the variable x3? 

A. Only the default constructor of class X 

B. Only the no-argument constructor of class Y 

C. Only the no-argument constructor of class Z 

D. Only the default constructor of object class 

Answer: