Q1. Given:
What three modifications, made independently, made to class greet, enable the code to compile and run?
A. line 6 replaced with handy.dandy.keystroke stroke = new KeyStroke ( );
B. line 6 replaced with handy.*.KeyStroke = new KeyStroke ( );
C. line 6 replaced with handy.dandy.KeyStroke Stroke = new handy.dandy.KeyStroke();
D. import handy.*; added before line 1
E. import handy.dandy.*; added after line 1
F. import handy.dandy,KeyStroke; added after line 1
G. import handy.dandy.KeyStroke.typeException(); added before line 1
Answer: CEF
Q2. Given:
What is the result?
A. 11, 21, 31, 11, 21, 31
B. 11, 21, 31, 12, 22, 32
C. 12, 22, 32, 12, 22, 32
D. 10, 20, 30, 10, 20, 30
Answer: D
Q3. What is the result?
A. Valid
B. Not valid
C. Compilation fails
D. An IllegalArgumentException is thrown at run time
Answer: C
Q4. 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
Q5. 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: D
Q6. racle 1z0-803 : Practice Test
j = (3 * ((2+4) + 5));
System.out.println("i:"+ i + "\nj":+j);
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q7. Which two statements are true for a two-dimensional array of primitive data type?
A. It cannot contain elements of different types.
B. The length of each dimension must be the same.
C. At the declaration time, the number of elements of the array in each dimension must be
specified.
D. All methods of the class object may be invoked on the two-dimensional array.
Answer: CD
Q8. Given:
Which two declarations will compile?
A. int a, b, c = 0;
B. int a, b, c;
C. int g, int h, int i = 0;
D. int d, e, F;
E. int k, l, m; = 0;
Answer: AD
Q9. Given the code fragment:
How many times is 2 printed?
A. Zero
B. Once
C. Twice
D. Thrice
E. It is not printed because compilation fails
Answer: B
Q10. Which code fragment, when inserted at line 9, enables the code to print true?
A. String str2 = str1;
B. String str2 = new string (str1);
C. String str2 = sb1.toString();
D. String str2 = “Duke”;
Answer: B
Q11. Which two items can legally be contained within a java class declaration?
A. An import statement
B. A field declaration
C. A package declaration
D. A method declaration
Answer: BD
Q12. 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: E
Q13. What is result?
A. Successful
B. Unsuccessful
C. Compilation fails
D. An exception is thrown at runtime
Answer: C
Q14. Given the code fragment:
Which statement is true?
A. After line 8, three objects are eligible for garbage collection
B. After line 8, two objects are eligible for garbage collection
C. After line 8, one object is eligible for garbage collection
D. After line 8, none of the objects are eligible for garbage collection
Answer: C
Q15. 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;
}
}
Given:
Public class TestStudent {
public static void main(String[] args) {
Student bob = new Student ();
bob.name = "Bob";
bob.age = 18;
bob.year = 1982;
}
}
What is the result?
A. year is set to 1982.
B. bob.year is set to 1982
C. A runtime error is generated.
D. A compile time error is generated.
Answer: D
Q16. Given:
What is the result?
A. Null
B. Compilation fails
C. An exception is thrown at runtime
D. 0
Answer: A