Exam 1 Flashcards
Object-oriented programming (OOP) is popular because:
- it enables reuse of previous code saved as classes
- which saves time because previously written code has been tested and debugged already
If a new class is similar to an existing class, the existing class can be:
Extended
This extension of an existing class is called:
Inheritance
Inheritance creates an is-a relationship, meaning the child is a more ___________________ of the parent.
Specific version
//mammal
drinkMothersMilk()
^
|
thinkCreatively()
A human is a:
Human has all the data fields and methods defined by:
Human is a __________ of mammal
Human may define other variables and methods that ______ contained in mammal
Mammal
Mammal
Subclass
Are not
The keyword ___________ creates an inheritance relationship
extends
Only ______________ need to be declared
Additional data fields
A notebook object contains the data fields declared in both the____________ and _____________ objects
Computer and notebook
If data fields are declared as __________ in the superclass, they are not directly accessible in the subclass
Private
If the execution of any constructor in a subclass does not invoke a superclass constructor—an explicit call to super()—java automatically invokes the __________________ for the superclass
No-parameter constructor
If no constructors are defined for a class, the _________________ for that class is provided by default
No-parameter constructors
If any _____________ are defined, you must explicitly define a no-parameter constructor
Constructor
Variables with a private visiability cannot be accessed by a:
Subclass
Variables with ___________ visibility are accessible by any subclass or any class in the same package
Protected
In general, it is better to use ____________ visibility and to restrict access to variables to accessor methods
Private