ICSI 201 – Chapter 6 Review Questions – Flashcards

Unlock all answers in this set

Unlock answers
question
Class
answer
This is a collection of programming statements that specify the fields and methods that a particular type of object may have.
question
Blueprint
answer
A class is analogous to a(n) ______.
question
Instance of a class
answer
An object is a(n) ______.
question
Field
answer
This is a class member that holds data.
question
new
answer
This key word causes an object to be created in memory.
question
Accessor
answer
This is a method that gets a value from a class's field, but does not change it.
question
Mutator
answer
This is a method that stores a value in a field or in some other way changes the value of a field.
question
Stale
answer
When the value of an item is dependent on other data, and that item is not updated when the other data is changed, what has the value become?
question
Constructor
answer
This is a method that is automatically called when an instance of a class is created.
question
Shadows
answer
When a local variable has the same name as a field, the local variable's name does this to the field's name.
question
Default Constructor
answer
This is automatically provided for a class if you do not write one yourself.
question
Their parameter lists
answer
Two or more methods in a class may have the same name, as long as this is different.
question
Binding
answer
The process of matching a method call with the correct method is known as ______.
question
Things the class knows and actions the class performs.
answer
A class's responsibilities are ______.
question
True
answer
The "new" operator creates an instance of a class. (T/F)
question
True
answer
Each instance of a class has its own set of instance fields. (T/F)
question
False
answer
When you write a constructor for a class, it still has the default constructor that Java automatically provides. (T/F)
question
False
answer
A class may not have more than one constructor. (T/F)
question
False
answer
To find the classes needed for an object-oriented application, you identify all the verbs in a description of the problem domain. (T/F)
question
A class is a blueprint or a representation of how an object has to be instantiated. The instance is the actual object created from the class at runtime.
answer
What is the difference between a class and an instance of a class?
question
Classes are analogous to the blueprint of the houses.
answer
A contractor uses a blueprint to build a set of identical houses. Are classes analogous to the blueprint or the houses?
question
An accessor method is a method that gets a value from a class's field but does not change it. A mutator method is a method that stores a value in a field or changes the value of a field in some other way.
answer
What is an accessor method? What is a mutator method?
question
It is a good idea to make a field private because it allows only the class's methods to directly access and make changes to the object's internal data, which protects it from corruption.
answer
Is it a good idea to make a field private? Why or why not?
question
If a class has a private field, only the class's methods may directly access and make changes to the object's internal data.
answer
If a class has a private field, what has access to the field?
question
It creates a new instance of an object or class; it is also used to create an array.
answer
What is the purpose of the "new" key word?
question
Constructors are a special type of method that is used to initialize the object. A constructor is invoked at the time of object creation. It constructs the values (i.e., provides data for the object).
answer
Why are constructors useful for performing "start-up" operations?
question
The only time that Java provides a default constructor is when you do not write your own constructor for a class.
answer
Under what circumstances does Java automatically provide a default constructor for a class?
question
No-arg constructor.
answer
What do you call a constructor that accepts no arguments?
question
You can have two methods of the same name so long as they have different signatures—this is called method overloading. The methods also have to return the same type of object, and have the same access modifier.
answer
When the same name is used for two or more methods in the same class, how does Java tell them apart?
question
When a method is overloaded, it means that multiple methods in the same class have the same name, but use different types of parameters. Method overloading is important because sometimes you need several different ways to perform the same operation, so method overloading provides greater flexibility than if it provided only one way to perform every operation.
answer
How does method overloading improve the usefulness of a class?
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New