Q1. Given:
What is the result?
A. Compilation fails
B. An exception is thrown at runtime
C. There is no result because this is not correct way to determine the hash code
D. Hash is: 111111, 44444444, 999999999
Answer: A
Q2. Given the code fragment:
What is the result?
A. 28false29 true
B. 285 < 429 true
C. true true
D. compilation fails
Answer: C
Q3. Given:
Which line causes a compilation error?
A. line x1
B. line x2
C. line x3
D. line x4
Answer: B
Q4. Identify two benefits of using ArrayList over array in software development.
A. reduces memory footprint
B. implements the Collection API
C. is multi.thread safe
D. dynamically resizes based on the number of elements in the list
Answer: AD
Q5. Given the code fragment:
What is the result?
A. 2 2
B. 1 2
C. 3 2
D. 3 3
Answer: A
Q6. Which statement initializes a stringBuilder to a capacity of 128?
A. StringBuilder sb = new String ("128");
B. StringBuilder sb = StringBuilder.setCapacity (128);
C. StringBuilder sb = StringBuilder.getInstance (128);
D. StringBuilder sb = new StringBuilder (128);
Answer: D
Q7. What is result?
A. Successful
B. Unsuccessful
C. Compilation fails
D. An exception is thrown at runtime
Answer: C
Q8. Given the code fragment:
What is the result?
A. Found Red
B. Found Red
Found Blue
C. Found Red
Found Blue
Found White
D. Found Red
Found Blue
Found White
Found Default
Answer: B
Q9. 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: C
Q10. Given:
What is the result?
A. 10 : 22 : 20
B. 10 : 22 : 22
C. 10 : 22 : 6
D. 10 : 30 : 6
Answer: B