QUESTION NO 
Exhibit:
1. public class Mycircle {
2. public double radius;
3. public double diameter;
4.
5. public void setRadius(double radius)
6. this.radius = radius;
7. this.diameter= radius * 2;
8. }
9.
10. public double getRadius() {
11. return radius;
12. }
13. }

Which statement is true?
A. The Mycircle class is fully encapsulated.
B. The diameter of a given MyCircle is guaranteed to be twice its radius.
C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation.
D. The radius of a MyCircle object can be set without affecting its diameter.

Given:
11. public static void main( String[] args ) {
12. Integer a = new Integer(10);
13. Integer b = new Integer(10);
14. Integer c = a;
15. int d = 10;
16. double e = 10.0;
17. }
Which three evaluate to true? (Choose three)
A. (a == c)
B. (d == e)
C. (b == d)
D. (a == b)
E. (b == c)
F. (d == 10.0)

Which two cause a compiler error? (Choose two)
A. float[] = new float(3);
B. float f2[] = new float[];
C. float[] f1 = new float[3];
D. float f3[] = new float[3];
E. float f5[] = { 1.0f, 2.0f, 2.0f };
F. float f4[] = new float[] { 1.0f. 2.0f. 3.0f};

Given:
1. public class ArrayTest {
2. public static void main(String[] args) {
3. float fl[], f2[];
4. fl = new float[10];
5. f2 = f1;
6. System.out.println(“f2[0]= “ + f2[0]);
7. }
8. }
What is the result?
A. It prints f2[0] = 0.0.
B. It prints f2[0] = NaN.
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an expectation at runtime.

Which three form part of correct array declarations? (Choose three)
A. public int a []
B. static int [] a
C. public [] int a
D. private int a [3]
E. private int [3] a []
F. public final int [] a

Given:
11. Float f = new Float(“12”);
12. switch (f) {
13. case 12: System.out.println(“Twelve”);
14. case 0: System.out.println(“Zero”);
15. default: System.out.println(“Default”);
16. }
What is the result?
A. Zero
B. Twelve
C. Default
D. Twelve
Zero
Default
E. Compilation fails.

Which three statements are true? (Choose three)
A. The default constructor initializes method variables.
B. The default constructor has the same access as its class.
C. The default constructor invoked the no-arg constructor of the superclass.
D. If a class lacks a no-arg constructor, the compiler always creates a default constructor.
E. The compiler creates a default constructor only when there are no other constructors
for the class.

Which two create an instance of an array? (Choose two)

A. int[] ia = new int[15];
B. float fa = new float[20];
C. char[] ca = “Some String”;
D. Object oa = new float[20];
E. int ia[][] = { 4, 5, 6, }, { 1, 2, 3 };

QUESTION NO: 
Given:
11. switch(x) {
12. default:
13. System.out.println(“Hello”);
14. }
Which two are acceptable types for x? (Choose two)
A. byte
B. long
C. char
D. float
E. Short
F. Long

Given:
1. public class Foo {
2. public void main( String[] args ) {
3. System.out.println( “Hello” + args[0] );
4. }
5. }
What is the result if this code is executed with the command line?
java Foo world
A. Hello
B. Hello Foo
C. Hello world
D. Compilation fails.
E. The code does not run.

Which two cause a compiler error? (Choose two)
A. int[] scores = {3, 5, 7};
B. int [][] scores = {2,7,6}, {9,3,45};
C. String cats[] = {“Fluffy”, “Spot”, “Zeus”};
D. boolean results[] = new boolean [3] {true, false, true};
E. Integer results[] = {new Integer(3), new Integer(5), new
Integer(8)};
F. String[] dogs = new String[]{new String(“Fido”),new
String(“Spike”), new String(“Aiko”)};

Given:
11. int x = 1, y =6;
12. while (y--) {
13. x++;
14. }
15. System.out.println(“x =” + x + “y =” +y);
What is the result?
A. x = 6 y = 0
B. x = 7 y = 0
C. x = 6 y = -1
D. x = 7 y = -1
E. Compilation fails.

QUESTION NO
Given:
12. float f[][][] = new float[3][][];
13. float f0 = 1.0f;
14. float[][] farray = new float[1][1];
What is valid?
A. f[0] = f0;
B. f[0] = farray;
C. f[0] = farray[0];
D. f[0] = farray[0][0];

QUESTION NO: discuss when teach strings
Given:
11. String a = null;
12. a.concat(“abc”);
13. a.concat(“def”);
14. System.out.println(a);
What is the result?
A. abc
B. null
C. abcdef
D. Compilation fails.
E. The code runs with no output.
F. An exception is thrown at runtime.

Which two are benefits of fully encapsulating a class? (Choose two)
A. Performance of class methods is improved.
B. Implementation details of the class are hidden.
C. Access modifiers can be omitted on class data members.
D. Code that uses the encapsulation class can access data members directly.
E. Internal operation of the class can be modified without impacting clients of that class.

QUESTION NO: 111
Given:
1. class A {
2. public A() {
3. System.out.println(“hello from a”);
4. }
5. }
6. class B extends A {
7. public B () {
8. System.out.println(“hello from b”);
9. super();

10 }
11. }
12. public class Test {
13. public static void main(String args[]) {
14. A a = new B();
15. }
16. }
What is the result when main is executed?
A. Compilation fails.
B. hello from a
C. hello from b
D. hello from b
hello from a
E. hello from a
hello from b
.

Which two are valid declarations of a float? (Choose two)
A. float f = 1F;
B. float f = 1.0.;
C. float f = ‘1’;
D. float f = “1”;
E. float f = 1.0d;

Given:
1. public class Test {
2. private static int[] x;
3. public static void main(String[] args) {
4. System.out.println(x[0]);
5. }
6. }
What is the result?
A. 0
B. null
C. Compilation fails.
D. A NullPointerException is thrown at runtime.
E. An ArrayIndexOutOfBoundsException is thrown at runtime.

What is the numerical range of a char?
A. 0 ... 32767
B. 0 ... 65535
C. –256 ... 255
D. –32768 ... 32767
E. Range is platform dependent.

Given:
1. public class Test {
2. private static float[] f = new float[2];
3. public static void main(String args[]) {
4. System.out.println(“f[0] = “ + f[0]);
5. }
6. }
What is the result?
A. f[0] = 0
B. f[0] = 0.0
C. Compilation fails.
D. An exception is thrown at runtime.

Given:
1. public class Test {
2. public static void main(String[] args) {
3. String str = NULL;
4. System.out.println(str);
5. }
6. }
What is the result?
A. NULL
B. Compilation fails.
C. The code runs with no output.
D. An exception is thrown at runtime.

Q
Which is a valid identifier?
A. false
B. default
C. _object
D. a-class

Given:
1. public class X {
2. public static void main (String[] args) {
3. byte b = 127;
4. byte c = 126;
5. byte d = b + c;
6. }
7. }
Which statement is true?
A. Compilation succeeds and d takes the value 253.
B. Line 5 contains an error that prevents compilation.
C. Line 5 throws an exception indicating “Out of range”
D. Line 3 and 4 contain error that prevent compilation.
E. The compilation succeeds and d takes the value of 1.

Given:
1. public class test (
2. public static void main (String args[]) {
3. int i = 0xFFFFFFF1;
4. int j = ~i;
5.
6. }
7. )
What is the decimal value of j at line 5?
A. 0
B. 1
C. 14
D. –15
E. An error at line 3 causes compilation to fail.
F. An error at line 4 causes compilation to fail.

Given:
Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);
Which two expressions evaluate to True? (Choose Two)
A. (i ==1)
B. (i == d)
C. (d == 1)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))

Q
2. private static int j = 0;
3.
4. private static boolean methodB(int k) (
5. j += k;
6. return true;
6. )
7.
8. public static void methodA(int i) {
9. boolean b:
10. b = i < 10 | methodB (4);
11. b = i < 10 || methodB (8);
12. )
13.
14. public static void main (String args[] } (
15. methodA (0);
16. system.out.printIn(j);
17. )
18. )
What is the result?
A. The program prints “0”
B. The program prints “4”
C. The program prints “8”
D. The program prints “12”
E. The code does not complete.

Given
1. Public class test (
2. Public static void main (String args[]) (
3. System.out.printIn (6 ^ 3);
4. )
5. )
What is the output?

Q
Which three are valid declarations of a float? (Choose Three)
A. Float foo = -1;
B. Float foo = 1.0;
C. Float foo = 42e1;
D. Float foo = 2.02f;
E. Float foo = 3.03d;
F. Float foo = 0x0123;

Given:
8. int index = 1;
9. int [] foo = new int [3];
10.int bar = foo [index];
11.int baz = bar + index;
What is the result?
A. Baz has the value of 0
B. Baz has the value of 1
C. Baz has the value of 2
D. An exception is thrown.
E. The code will not compile.

Given:
1. public class foo {
2. public static void main (String[]args) {
3. String s;
4. system.out.printIn (“s=” + s);
5. }
6. }
What is the result?
A. The code compiles and “s=” is printed.
B. The code compiles and “s=null” is printed.
C. The code does not compile because string s is not initialized.
D. The code does not compile because string s cannot be referenced.
E. The code compiles, but a NullPointerException is thrown when toString is
called.

Given:
1. byte [] arry1, array2[];
2. byte array3 [][];
3. byte[][] array4;
If each array has been initialized, which statement will cause a compiler error?
A. Array2 = array1;
B. Array2 = array3;
C. Array2 = array4;
D. Both A and B
E. Both A and C
F. Both B and C

1. public class ArrayTest {
2. public static void main (String[]args) {
3. float f1[], f2[];
4. f1 = new float [10];
5. f2 = f1;
6. System.out.printIn (“f2[0]=” + f2[0]);
7. }
8. }
What is the result?
A. It prints f2[0] = 0.0
B. It prints f2[0] = NaN
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an exception at runtime.

Which two statements are true regarding the creation of a default constructor? (Choose
Two)
A. The default constructor initializes method variables.
B. The compiler always creates a default constructor for every class.
C. The default constructor invokes the no-parameter constructor of the superclass.
D. The default constructor initializes the instance variables declared in the class.
E. When a class has only constructors with parameters, the compiler does not create
a default constructor.

Which is a valid identifier?
A. false
B. default
C. _object
D. a-class

Given:
8. int index = 1;
9. String [] test = new String[3];
10. String foo = test[index];
What is the result?
E. Foo has the value “”
B. Foo has the value null
C. An exception is thrown
D. The code will not compile

Given:
1. public class foo {
2. static String s;
3. public static void main (String[]args) {
4. system.out.printIn (“s=” + s);
5. }
6. }
What is the result?
A. The code compiles and “s=” is printed.
B. The code compiles and “s=null” is printed.
C. The code does not compile because string s is not initialized.
D. The code does not compile because string s cannot be referenced.
E. The code compiles, but a NullPointerException is thrown when toString is
called.

Which two valid declarations of a char? (Choose Two)
A. Char ch = “a”;
B. Char ch = ‘\’ ‘;
C. Char ch = ‘cafe’;
D. Char ch = “cafe”;
E. Char ch = ‘\ucafe’;
F. Char ch = ‘\u10100’;
G. Char ch = (char) true;