Chapter 3 - Exercises
Chapter 3 - Exercises
EXERCISES
I NSTRU CTOR
D R . A B ED EL S AFADI
6. Converting from a value of primitive type to a corresponding object of its associated wrapper
class is called:
a. Boxing
b. Unboxing
c. Converting
d. Reinstantiating
7. The conversion from an object of a wrapper class to a value of its associated primitive type is
called:
a. Boxing
b. Unboxing
c. Converting
d. Reinstantiating
7. You should add the static keyword in the place of ? in Line ________ in the following code:
a. The code has a compile error because xMethod does not return a value.
b. The code has a compile error because xMethod is not declared static.
c. The code prints n is 1.
d. The code prints n is 2.
e. The code prints n is 3.
Exercises – Chapter 3 Page 6 of 8
9. What is the output of the following code?
a. f2.i is 1 f2.s is 1
b. f2.i is 1 f2.s is 2
c. f2.i is 2 f2.s is 2
d. f2.i is 2 f2.s is 1
a. f3.i is 1 f3.s is 1
b. f3.i is 1 f3.s is 2
c. f3.i is 1 f3.s is 3
d. f3.i is 3 f3.s is 1
e. f3.i is 3 f3.s is 3
CODING EXERCISES II
PROGRAM 1