1. See the section "Declaring and Creating Objects."
2. Constructors are special kinds of methods that are called when creating an object using the new operator. Constructors do not have a return type—not even void.
3. Java uses “pass by value” to pass parameters to a method. When passing a variable of a primitive type to a method, the variable remains unchanged after the method finishes. However, when passing a variable of a reference type to a method, any changes to the object referenced by the variable inside the method are permanent changes to the object referenced by the variable outside of the method. Both the actual parameter and the formal parameter variables reference to the same object.
The output of the program is as follows:
count 101
times 0
4.

5. System.out.println(f.i);
Answer: Correct
System.out.println(f.s);
Answer: Correct
f.imethod();
Answer: Correct
f.smethod();
Answer: Correct
System.out.println(Foo.i);
Answer: Incorrect
System.out.println(Foo.s);
Answer: Correct
Foo.imethod();
Answer: Incorrect
Foo.smethod();
Answer: Correct
6. i + j is 23 (because i (value of 2) is concatenated with string j + j is, then j (value of 3) is concatenated with string i + j is 2.)
k is 2
j is 0
7. i is not initialized before it is used in the println().
8. The program has a syntax error because i is not defined before it is used in the println() statement.
9. public, private, and static. See the section "Modifiers" for descriptions of each modifier.
10. The keyword this refers to the object itself.
11. b
12. b, because new C(5.0) does not match any constructors in class C.
13. d
14. e.
15. a is incorrect, since x can be accessed by an object of Foo inside the Foo class.
b is incorrect because x is non-static, it cannot be accessed in the main method without creating an object. d is incorrect, since it is permissible to create an instance of the class within the class. The best choice is c.
16. Yes. Though radius is private, myCircle.radius is used inside the Circle class. Thus, it is fine.
17. An array is an object. The default value for the elements of an array is 0 for numeric, false for boolean, ‘\u0000’ for char, null for object element type.
18. a. a[0] = 1 a[1] = 2
b. a[0] = 2 a[1] = 1
c. e1 = 2 e2 = 2
d. t1’s i = 2 t1’s j = 1
t2’s i = 2 t2’s j = 1