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)ba class, derived class
(b)derived class, ba class
(c)inherited class, ba class师范类院校排名
(d)ba class, inherited class
Answer:B
2)Inheritance promotes code ___________.
(a)reinvention
(b)reu
(c)repeats
疏的意思rectus(d)all of the above
Answer:B
3)The keyword extends indicates:
(a)encapsulation
(b)polymorphism
(c)inheritance
(d)none of the above
betsyAnswer:C
4) A derived class is also called a
(a)sub class
(b)super class
(c)ba class
(d)all of the above
Answer:A
Copyright ? 2006 Pearson Education Addison-Wesley. All rights rerved. 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 class
jbm(d)ba class
Answer:D
6)What does a derived class automatically inherit from the ba 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.
cebit
(d)None of the above.
Answer:C
8) A ba 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 ba class is:
(a)super()
载体英语(b)ba()
(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 ba
class, and more generally, has the type of every one of its ___________ class.
(a)descendant
(b)child
(c)ancestor
(d)sub
Answer:C
Copyright ? 2006 Pearson Education Addison-Wesley. All rights rerved.
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 accesd by name inside its own class definitions.
(b)can not be accesd by name inside any class derived from it.
(c)can not be accesd by name in the definition of any class in the same package.
直辖市英语(d)can not be accesd by name in any other class (that is, other than class 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 class.
(a)String
(b)Object
(c)Math
(d)JFrame
Answer:B
15)The Object class contains the method:
(a)getClass()chennai
(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 rerved.
4 Walter Savitch ?Absolute Java 2/e Chapter 7 Test Bank
True/Fal
1) A derived class contains only public instance variables and public methods from the ba class.
Answer:Fal
2)Inheritance refers to a very specialized form of a class.
Answer:Fal
3) A derived class is a class defined by adding instance variables and methods to an exist
ing class.