Q1. 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: A
Q2. Given:
What should statement1, statement2, and statement3, be respectively, in order to produce the result?
Shape: constructor
Square: foo
Shape: foo
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Answer: D
Q3. Given:
What is the result?
A. 0
B. 0 1 2
C. 0 1 2 0 1 2 0 1 2
D. Compilation fails
Answer: B
Q4. Which code fragments, inserted independently, enable the code compile?
A. t.fvar = 200;
B. cvar = 400;
C. fvar = 200; cvar = 400;
D. this.fvar = 200; this.cvar = 400;
E. t.fvar = 200; Test2.cvar = 400;
F. this.fvar = 200; Test2.cvar = 400;
Answer: B
Q5. boolean log3 = ( 5.0 != 6.0) && ( 4 != 5);
boolean log4 = (4 != 4) || (4 == 4);
System.out.println("log3:"+ log3 + \nlog4" + log4);
What is the result?
A. log3:false log4:true
B. log3:true log4:true
C. log3:true log4:false
D. log3:false log4:false
Answer: B
Q6. Which two statements are true for a two-dimensional array?
A. It is implemented as an array of the specified element type.
B. Using a row by column convention, each row of a two-dimensional array must be of the same size.
C. At 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: AD
Q7. What is the result?
A. 3 false 1
B. 2 true 3
C. 2 false 3
D. 3 true 1
E. 3 false 3
F. 2 true 1
G. 2 false 1
Answer: D
Q8. Which three are valid types for switch?
A. int
B. float
C. double
D. integer
E. String
F. Float
Answer: ADE
Q9. 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
Q10. Which two are valid array declaration?
A. Object array[];
B. Boolean array[3];
C. int[] array;
D. Float[2] array;
Answer: AC
Q11. Given the code fragment:
A. Found Red
Found Default
B. Found Teal
C. Found Red
Found Blue
Found Teal
D. Found Red
Found Blue
Found Teal
Found Default
E. Found Default
Answer: B
Q12. 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
Q13. Given:
Which two classes use the shape class correctly?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Answer: BE
Q14. 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
Q15. given:
A. ns = 50 S = 125
ns = 125 S = 125
ns = 100 S = 125
B. ns = 50 S = 125
ns = 125 S = 125
ns = 0 S = 125
C. ns = 50 S = 50
ns = 125 S = 125
ns = 100 S = 100
D. ns = 50 S = 50
ns = 125 S = 125
ns = 0 S = 125
Answer: B
Q16. Given:
Which statement, when inserted into line 5, is valid change?
A. asc = sc;
B. sc = asc;
C. asc = (object) sc;
D. asc = sc.clone ()
Answer: B