Deck 7: Inheritance

Full screen (f)
exit full mode
Question
A base class is synonymous with a:
(a)Child class
(b)Parent class
(c)Derived class
(d)Sub class
Use Space or
up arrow
down arrow
to flip the card.
Question
If an instance variable is not modified by public,protected or private then it is said to have:
(a)Package access
(b)Default access
(c)Friendly access
(d)All of the above
Question
The special syntax for invoking a constructor of the base class is:
(a)super()
(b)base()
(c)parent()
(d)child()
Question
A super class is also called a
(a)derived class
(b)dominant class
(c)sub class
(d)base class
Question
When you define a derived class,you give only the added instance variables and the added methods as well as all the methods from the base class.
Question
What does a derived class automatically inherit from the base class?
(a)instance variables
(b)static variables
(c)public methods
(d)all of the above
Question
Inheritance refers to a very specialized form of a class.
Question
A method or instance variable modified by protected:
(a)can not be accessed by name inside its own class definitions.
(b)can not be accessed by name inside any class derived from it.
(c)can not be accessed by name in the definition of any class in the same package.
(d)can not be accessed by name in any other class (that is,other than classes named in a-c.).
Question
The keyword extends indicates:
(a)encapsulation
(b)polymorphism
(c)inheritance
(d)none of the above
Question
The equals method for a class should have _________ as the type of its one parameter.
(a)String
(b)Object
(c)Integer
(d)Double
Question
In using the keyword this in place of super(),the invocation of this must be the ___________ action taken by the constructor.
(a)first
(b)last
(c)it does not matter
(d)none of the above
Question
The Object class contains the method:
(a)getClass()
(b)toString()
(c)equals()
(d)all of the above
Question
A derived class contains only public instance variables and public methods from the base class.
Question
The class __________ is an ancestor class of all Java classes.
(a)String
(b)Object
(c)Math
(d)JFrame
Question
If the final modifier is added to the definition of a method,this means:
(a)The method may be redefined in the derived class.
(b)The method may be redefined in the sub class.
(c)The method may not be redefined in the derived class.
(d)None of the above.
Question
Inheritance is the process by which a new class - known as a _________ - is created from another class,called the _____________.
(a)base class,derived class
(b)derived class,base class
(c)inherited class,base class
(d)base class,inherited class
Question
A derived class is also called a
(a)sub class
(b)super class
(c)base class
(d)all of the above
Question
An object of a derived class has the type of the derived class,and it also has the type of the base class,and more generally,has the type of every one of its ___________ classes.
(a)descendant
(b)child
(c)ancestor
(d)sub
Question
Inheritance promotes code ___________.
(a)reinvention
(b)reuse
(c)repeats
(d)all of the above
Question
A derived class is a class defined by adding instance variables and methods to an existing class.
Question
Write Java statements that compares Objects,O1 and O2,using the getClass()method.
Question
The call to the base class constructor (super)must always be the last action taken in a constructor definition.
Question
Explain what a call to super()does in a constructor of a derived class.
Question
What is encapsulation?
Question
The keyword extends indicates polymorphism.
Question
Explain the difference between method overloading and method overriding.
Question
What does the instanceof operator do?
Question
Create a test driver to test the functionality of your AlarmClock class created in number 3 above.
Question
Explain the modifiers public,protected and private.
Question
Define a derived class to represent an alarm clock.Use the Clock class,created in number 2 above,as your base class.
Question
What is an "is a" relationship? How does it apply to the world of objects?
Question
An instance variable (or method)that is private in a base class is accessible by name in the definition of a method in any other class.
Question
What is package access?
Question
You may substitute the keyword this for super()to call a constructor of the derived class.
Question
What is a "has a" relationship?
Question
Private methods of the base class are not available for use by derived classes.
Question
Overriding is when a derived class redefines a method from the base class.
Question
A constructor for a derived class begins with an invocation of a constructor for the base class.
Question
Define a base class to represent a Clock.Your class should have instance variables for hours,minutes and seconds.
Question
Explain how parent and child classes are related to base and derived classes.
Question
Create a test driver to test the functionality of your Rectangle class created in number 14 above.
Question
What are the different ways in which you can check the class of an Object?
Question
Create a class to represent a Rectangle.Your class should contain instance variables for length and width,as well as member method to calculate the area and perimeter.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/43
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Inheritance
1
A base class is synonymous with a:
(a)Child class
(b)Parent class
(c)Derived class
(d)Sub class
B
2
If an instance variable is not modified by public,protected or private then it is said to have:
(a)Package access
(b)Default access
(c)Friendly access
(d)All of the above
D
3
The special syntax for invoking a constructor of the base class is:
(a)super()
(b)base()
(c)parent()
(d)child()
A
4
A super class is also called a
(a)derived class
(b)dominant class
(c)sub class
(d)base class
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
5
When you define a derived class,you give only the added instance variables and the added methods as well as all the methods from the base class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
6
What does a derived class automatically inherit from the base class?
(a)instance variables
(b)static variables
(c)public methods
(d)all of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
7
Inheritance refers to a very specialized form of a class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
8
A method or instance variable modified by protected:
(a)can not be accessed by name inside its own class definitions.
(b)can not be accessed by name inside any class derived from it.
(c)can not be accessed by name in the definition of any class in the same package.
(d)can not be accessed by name in any other class (that is,other than classes named in a-c.).
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
9
The keyword extends indicates:
(a)encapsulation
(b)polymorphism
(c)inheritance
(d)none of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
10
The equals method for a class should have _________ as the type of its one parameter.
(a)String
(b)Object
(c)Integer
(d)Double
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
11
In using the keyword this in place of super(),the invocation of this must be the ___________ action taken by the constructor.
(a)first
(b)last
(c)it does not matter
(d)none of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
12
The Object class contains the method:
(a)getClass()
(b)toString()
(c)equals()
(d)all of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
13
A derived class contains only public instance variables and public methods from the base class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
14
The class __________ is an ancestor class of all Java classes.
(a)String
(b)Object
(c)Math
(d)JFrame
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
15
If the final modifier is added to the definition of a method,this means:
(a)The method may be redefined in the derived class.
(b)The method may be redefined in the sub class.
(c)The method may not be redefined in the derived class.
(d)None of the above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
16
Inheritance is the process by which a new class - known as a _________ - is created from another class,called the _____________.
(a)base class,derived class
(b)derived class,base class
(c)inherited class,base class
(d)base class,inherited class
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
17
A derived class is also called a
(a)sub class
(b)super class
(c)base class
(d)all of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
18
An object of a derived class has the type of the derived class,and it also has the type of the base class,and more generally,has the type of every one of its ___________ classes.
(a)descendant
(b)child
(c)ancestor
(d)sub
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
19
Inheritance promotes code ___________.
(a)reinvention
(b)reuse
(c)repeats
(d)all of the above
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
20
A derived class is a class defined by adding instance variables and methods to an existing class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
21
Write Java statements that compares Objects,O1 and O2,using the getClass()method.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
22
The call to the base class constructor (super)must always be the last action taken in a constructor definition.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
23
Explain what a call to super()does in a constructor of a derived class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
24
What is encapsulation?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
25
The keyword extends indicates polymorphism.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
26
Explain the difference between method overloading and method overriding.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
27
What does the instanceof operator do?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
28
Create a test driver to test the functionality of your AlarmClock class created in number 3 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
29
Explain the modifiers public,protected and private.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
30
Define a derived class to represent an alarm clock.Use the Clock class,created in number 2 above,as your base class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
31
What is an "is a" relationship? How does it apply to the world of objects?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
32
An instance variable (or method)that is private in a base class is accessible by name in the definition of a method in any other class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
33
What is package access?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
34
You may substitute the keyword this for super()to call a constructor of the derived class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
35
What is a "has a" relationship?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
36
Private methods of the base class are not available for use by derived classes.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
37
Overriding is when a derived class redefines a method from the base class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
38
A constructor for a derived class begins with an invocation of a constructor for the base class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
39
Define a base class to represent a Clock.Your class should have instance variables for hours,minutes and seconds.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
40
Explain how parent and child classes are related to base and derived classes.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
41
Create a test driver to test the functionality of your Rectangle class created in number 14 above.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
42
What are the different ways in which you can check the class of an Object?
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
43
Create a class to represent a Rectangle.Your class should contain instance variables for length and width,as well as member method to calculate the area and perimeter.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 43 flashcards in this deck.