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++;
Which of the following statements are valid in Java?
(i) bigRect.set(10, 5};
(ii) bigRect.length = 10;
bigRect.width = 5;
Only (i)
T/F A class and its members can be described graphically using Unified Modeling Language (UML) notation.
TRUE
T/F
If the object is created in a user program, then the object can access both the public and private members of the class.
FALSE
T/F When no object of the class type is instantiated static data members of the class fail to exist.
FALSE
Which of the following statements are valid in Java?
(i) person2 = person1;
(ii) n = person1.getName(); a = person1.getAge(); h = person1.getHeight(); w = person1.getWeight(); person2.set(n, a, h, w);
Both (i) and (ii)
T/F If a member of a class is public you cannot access it outside the class.
FALSE
T/F If a member of a class is a method, it can directly access any member of the class.
TRUE
T/F
A constructor has the same name as the class.
TRUE
T/F
You cannot override the default definition of the method: toString because it’s provided by Java.
FALSE
Which of the following words indicates an object’s reference to itself?
This
T/F A class can have only one constructor.
FALSE