1Z0-803 Premium Bundle

1Z0-803 Premium Bundle

Java SE 7 Programmer I Certification Exam

4.5 
(10380 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
May 20, 2024Last update

Oracle 1Z0-803 Free Practice Questions

Q1. public class StringReplace { 

public static void main(String[] args) { 

String message = "Hi everyone!"; 

System.out.println("message = " + message.replace("e", "X")); } 

What is the result? 

A. message = Hi everyone! 

B. message = Hi XvXryonX! 

C. A compile time error is produced. 

D. A runtime error is produced. 

E. message = 

F. message = Hi Xveryone! 

Answer:

Q2. You are writing a method that is declared not to return a value. Which two are permitted in 

the method body? 

A. omission of the return statement 

B. return null; 

C. return void; 

D. return; 

Answer: AD 

Q3. Given the code fragment: 

Which code fragment, when inserted at // insert code here, enables the code to compile and and print a b c? 

A. List update (String[] strs) 

B. Static ArrayListupdate(String [] strs) 

C. Static List update (String [] strs) 

D. Static void update (String[] strs) 

E. ArrayList static update(String [] strs) 

Answer:

Q4. Which two will compile, and can be run successfully using the command: 

Java fred1 hello walls 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer: CD 

Q5. Given the code fragment: 

What is the result? 

A. 28false29 true 

B. 285 < 429 true 

C. true true 

D. compilation fails 

Answer:

Q6. 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 

Q7. What is the result? 

A. 6 7 8 

B. 7 8 9 

C. 0 1 2 

D. 6 8 10 

E. Compilation fails 

Answer:

Q8. Give: 

What is the result? 

A. 1525 

B. 13 

C. Compilation fails 

D. An exception is thrown at runtime 

E. The program fails to execute due to runtime error 

Answer:

Q9. Given the following code fragment: 

What is the result if the integer value is 33? 

A. The fox jump lazy … 

B. The fox lazy … 

C. Quick fox over lazy … 

D. Quick fox the …. 

Answer:

Q10. What is the result? 

A. Initialized 

Started 

B. Initialized 

Started 

Initialized 

C. Compilation fails 

D. An exception is thrown at runtime 

Answer:

Q11. Given: 

What is the result? 

A. 1 1 1 

B. 1 2 3 

C. 2 3 4 

D. Compilation fails 

E. The loop executes infinite times 

Answer:

Q12. Given the code fragment:

A. 20 

B. 25 

C. 29 

D. Compilation fails 

E. An Array Index Out Of Bounds Exception is thrown at runtime 

Answer:

Q13. Given the code fragment: 

What values of x, y, z will produce the following result? 

1 2 3 4 

1 2 3 4 

1 2 3 4 

1 2 3 4 

A. X = 4, Y = 3, Z = 2 

B. X = 3, Y = 2, Z = 3 

C. X = 2, Y = 3, Z = 3 

D. X = 4, Y = 2, Z = 3 

E. X = 2, Y = 3, Z = 4 

Answer:

Q14. Given the following code: 

What will make this code compile and run? 

A. Change line 2 to the following: 

Public int price 

B. Change line 4 to the following: 

int price = new simple (); 

C. Change line 4 to the following: 

Float price = new simple (); 

D. Change line 5 to the following: 

Price = 4f; 

E. Change line 5 to the following: 

price.price = 4; 

F. Change line 5 to the following: 

Price = (float) 4: 

G. Change line 5 to the following: 

Price = (Simple) 4; 

H. The code compiles and runs properly; no changes are necessary 

Answer:

Q15. Given: 

Javac Jump.java 

Java Jump crazy elephant is always 

What is the result? 

A. Lazy lion is jumping 

B. Lion is always jumping 

C. Crazy elephant is jumping 

D. Elephant is always jumping 

E. Compilation fails 

Answer:

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

START 1Z0-803 EXAM