JAVA练习题含答案-answertopractice7
Chapter 7
Inheritance
Multiple Choice
1)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
Answer:B
2)Inheritance promotes code ___________.
(a)reinvention
(b)reuse
(c)repeats
(d)all of the above
Answer:B
3)The keyword extends indicates:
(a)encapsulation
(b)polymorphism
(c)inheritance
(d)none of the above
Answer:C
4) A derived class is also called a
(a)sub class
(b)super class
(c)base class
(d)all of the above
Answer:A
Copyright ? 2006 Pearson Education Addison-Wesley. All rights reserved. 1
2 Walter Savitch ?Absolute Java 2/e Chapter 7 Test Bank
5) A super class is also called a
(a)derived class
(b)dominant class
(c)sub classobject to
(d)base class
Answer:D
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
Answer:D
7)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.
Answer:C
8) A base class is synonymous with a:
(a)Child class
(b)Parent class
(c)Derived class
(d)Sub class
Answer:B
9)The special syntax for invoking a constructor of the base class is:
(a)super()
(b)base()
(c)parent()
(d)child()
Answer:A
10)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
Answer:C
Copyright ? 2006 Pearson Education Addison-Wesley. All rights reserved.
Chapter 7 Inheritance 3 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
Answer:A
12) 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.).
Answer:D
13)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
Answer:D
14)The class __________ is an ancestor class of all Java classes.
(a)String
(b)Object
(c)Math
(d)JFrame
Answer:B
15)The Object class contains the method:
(a)getClass()
(b)toString()
(c)equals()
(d)all of the above
Answer:D
16)The equals method for a class should have _________ as the type of its one parameter.
(a)String
(b)Object
(c)Integer
(d)Double
Answer:B
Copyright ? 2004 Addison-Wesley. All rights reserved.
4 Walter Savitch ?Absolute Java 2/e Chapter 7 Test Bank
True/False
1) A derived class contains only public instance variables and public methods from the base class.
Answer:False
2)Inheritance refers to a very specialized form of a class.
Answer:False
3) A derived class is a class defined by adding instance variables and methods to an exist
ing class.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论