Quick Guide: java se 7 programmer i 1z0 803
The article at Testaimer.com going over http://www.testaimer.com/1Z0-803-test is very comprehensive.
Q21. 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
Q22. Given:
What will be the output?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Q23. 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: B
Q24. Given:
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C
Q25. Given:
What is the result?
A. Compilation fails
B. The code compiles, but does not execute.
C. Paildrome
D. Wow
E. Mom
Answer: B
Q26. Which statement will empty the contents of a StringBuilder variable named sb?
A. sb.deleteAll();
B. sb.delete(0, sb.size());
C. sb.delete(0, sb.length());
D. sb.removeAll();
Answer: C
Q27. Which three statements are benefits of encapsulation?
A. Allows a class implementation to change without changing t he clients
B. Protects confidential data from leaking out of the objects
C. Prevents code from causing exceptions
D. Enables the class implementation to protect its invariants
E. Permits classes to be combined into the same package
F. Enables multiple instances of the same class to be created safely
Answer: ABD
Q28. 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: D
Q29. 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: D
Q30. 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: B