Ch8 Quiz review Flashcards
The ____ of a class are called the members of a class.
Components
T/F
Finalizers are value-returning methods that return the final value of a variable.
FALSE
T/F Members of a class consist of packages, methods, and libraries.
FALSE
T/F
You can import your classes the same way you import Java classes.
TRUE
Which of the following set of statements are valid in Java?
(i) bigRect.area();
bigRect.perimeter();
bigRect.print();
(ii) bigRect.area = bigRect.area();
bigRect.perimeter = bigRect.perimeter();
bigRect.print();
Only (i)
How do you declare a new reference variable of the type Illustrate and instantiate the object with a value of 9?
Illustrate illObject = new Illustrate(9);
What is the function of the reserved word class?
It defines only a data type / does not allocate memory
T/F An accessor method of a class first accesses the values of the data members of the class and then changes the value of the data members.
FALSE
In ___ copying, each reference variable refers to its own object.
Deep
T/F
In shallow copying, each reference variable refers to its own object.
FALSE
T/F The method finalize automatically executes when the class object goes out of scope.
TRUE
Which statement correctly instantiates the Rectangle object myRectangle?
(i) myRectangle Rectangle = new Rectangle (10,12);
(ii) class myRectangle = new Rectangle (10,12);
(iii) Rectangle myRectangle = new Rectangle (10,12);
Only (iii)
T/F
The following statement is legal:
aa.print();
TRUE
What is the main use of inner classes?
To handle events
T/F The components of a class are called fields.
FALSE
T/F
Modifiers are used to altar the behavior of the class.
TRUE
When does the method finalize execute?
When the class object goes out of scope
Which of the following statements are valid in Java?
(i) r = console.nextDouble();
myCircle.area = 3.14 * r * r;
System.out.println(myCircle.area);
(ii) r = console.nextDouble();
myCircle.set(r);
System.out.println(myCircle.area);
Only ii
What is a constructor without parameters?
Default constructor
T/F
The built in operation that is valid for classes is the dot (.) operator
TRUE
What does the constructor do in the class definition above? //missing info above
Sets value of X to 1
T/F If a class method is used to implement a binary operation on the class objects; then the method must have two parameters of the class type.
FALSE
T/F
The following statement is legal:
aa.x = 10;
FALSE
Which of the following statements is illegal? //missing info
Illustrate.x++;