1Z0-803 Exam - Java SE 7 Programmer I

certleader.com

Q1. Given: 

A. a, e i, o 

B. a, e o, o 

C. e, e I, o 

D. e, e o, o 

Answer:

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

Q3. A method doSomething () that has no exception handling code is modified to trail a method that throws a checked exception. Which two modifications, made independently, will allow the program to compile? 

A. Catch the exception in the method doSomething(). 

B. Declare the exception to be thrown in the doSomething() method signature. 

C. Cast the exception to a RunTimeException in the doSomething() method. 

D. Catch the exception in the method that calls doSomething(). 

Answer: AB 

Q4. Given: 

Which two modifications are necessary to ensure that the class is being properly encapsulated? 

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

A. Remove the area field. 

B. Change the getArea( ) method as follows: public double getArea ( ) { return Match.PI * radius * radius; } 

C. Add the following method: public double getArea ( ) {area = Match.PI * radius * radius; } 

D. Change the cacess modifier of the SerRadius ( ) method to be protected. 

Answer: BD 

Q5. Given the code fragment: 

int [][] array2d = new int[2][3]; 

System.out.println("Loading the data."); 

for ( int x = 0; x < array2d.length; x++) { 

for ( int y = 0; y < array2d[0].length; y++) { 

System.out.println(" x = " + x); 

System.out.println(" y = " + y); 

// insert load statement here. 

System.out.println("Modify the data. "); 

for ( int x = 0; x < array2d.length; x++) { 

for ( int y = 0; y < array2d[0].length; y++) { 

System.out.println(" x = " + x); 

System.out.println(" y = " + y); 

// insert modify statement here. 

Which pair of load and modify statement should be inserted in the code? The load 

statement should set the array's x row and y column value to the sum of x and y 

The modify statement should modify the array's x row and y column value by multiplying it by 2 

A. Load statement: array2d(x,y) = x + y; 

Modify statement: array2d(x,y) = array2d(x,y) * 2 

B. Load statement: array2d[x y] = x + y; 

Modify statement: array2d[x y] = array2d[x y] * 2 

C. Load statement: array2d[x,y] = x + y; 

Modify statement: array2d[x,y] = array2d[x,y] * 2 

Oracle 1z0-803 : Practice Test 

D. Load statement: array2d[x][y] = x + y; 

Modify statement: array2d[x][y] = array2d[x][y] * 2 

E. Load statement: array2d[[x][y]] = x + y; 

Modify statement: array2d[[x][y]] = array2d[[x][y]] * 2 

Answer:

Q6. Given the code fragment: 

What is the result? 

A. 10 8 6 4 2 0 

B. 10 8 6 4 2 

C. An Arithmetic Exception is thrown at runtime 

D. The program goes into an infinite loop outputting: 10 8 6 4 2 0. . . 

E. Compilation fails 

Answer:

Q7. Given: 

Which code fragment, when inserted at line 7, enables the code print true? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q8. View the exhibit: 

public class Student { 

public String name = ""; 

public int age = 0; 

public String major = "Undeclared"; 

public boolean fulltime = true; 

public void display() { 

System.out.println("Name: " + name + " Major: " + major); } 

public boolean isFullTime() { 

return fulltime; 

Which line of code initializes a student instance? 

A. Student student1; 

B. Student student1 = Student.new(); 

C. Student student1 = new Student(); 

D. Student student1 = Student(); 

Answer:

Q9. Why will the code not compile? 

A. A static field cannot be private. 

B. The getLetter method has no body. 

C. There is no setLetter method. 

D. The letter field is uninitialized. 

E. It contains a method named Main instead of ma 

Answer:

Q10. What is the proper way to defined a method that take two int values and returns their sum as an int value? 

A. int sum(int first, int second) { first + second; } 

B. int sum(int first, second) { return first + second; } 

C. sum(int first, int second) { return first + second; } 

D. int sum(int first, int second) { return first + second; } 

E. void sum (int first, int second) { return first + second; } 

Answer: