quiz2b Flashcards
T/F: objects are the instances of their classes
true
what declarations does a class contain
data declarations and method declarations
data declarations example
int size, char category
instance variable
a field that’s defined in a class and is allocated when an object is instantiated
class data
static data that all objects share
members
fields and methods that belong to the same class
access modifier
defines the circumstances under which a method or class can be accessed
the most liberal type of access
public access
public access
the usual declaration of classes; methods called by the client of the class
private access
the usual declaration of instance variables; methods called by other methods of the class
T/F: constructors hav a return value
false (constructors have no return value, it will cause compiler errors)
T/F: a class can have several constructors
true
the job of the class constructor
initialize the instance variables of the new object
T/F: a static method can access instance variables
false (static methods are associated with the class, so they don’t have access to the implicit parameter “this”)
T/F: a private method can be accessed by client code
false (nothing outside the class can access private methods)
T/F: a private attribute can be accessed within the equals method
true (it depends because if the equals method is inside, then it can access it, but if it’s outside, the it can’t access it)
T/F: instance attributes should be declared public
false (all instance attributes should be private)
T/F: all instance methods should ALWAYS be declared public
false (you can have private helper methods)
T/F: the return for accessors is usually void
false (an accessor is a getter, so if you have to give it back you can’t return void)