Chapter 7 - Classes and Objects
The format specifier_____is used to output values of type float or double. Which is it? 1. %f 2. %d 3. %s 4. %t
%f
A reference variable that is a reference to an object is used to invoke a method. True or false?
True
Reference-type instance variables are initialized by default to the value null. True or false?
True
Variables or methods declared with access modifier public are accessible wherever the program has a reference to an object of the class. True or false?
True
Gradebook myGradeBook = new Gradebook(); Which is true? 1. a constructor 2. creating an object to reference the class 3. a special method that has to have the same name as the class 4. all of the above
all of the above
When an object of a class maintains its own copy of an attribute, the field that represents the attribute is also known as a(n) _______.
instance variable
Fields (non-static class level variables) are ___ that store data. Which is it? 1. instance variables 2. private variables 3. object variables
instance variables
To use the methods in a class such as Scanner, you first have to ___ an object of the class and use it to call the methods. Which is it? 1. instantiate 2. initiate 3. incriminate 4. inginate
instantiate
The keyword public is an access ______. Which is it? 1. qualifier 2. instance 3. modifier
modifier
Keyword____requests memory from the system to store an object, then calls the corresponding class' constructor to initialize the object. Which is it? 1. public 2. new 3. private
new
Are import declaration required? Which is the right answer? 1. required 2. not required when one class in a package uses another in the same package 3. not required if always refer to a class with its full class name 4. 2 & 3 5. 1 & 3 6. 1 & 2
2 & 3