Unformatted text preview:

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)2 Inheritance promotes code ___________.()a reinvention()b reuse()c repeats()d all of the above)3 The keyword extends indicates:()a encapsulation()b polymorphism()c inheritance()d none of the above)4 A derived class is also called a()a sub class()b super class()c base class()d all of the above)5 A super class is also called a()a derived class()b dominant class()c sub class()d base class)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)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.)8 A base class is synonymous with a:()a Child class()b Parent class()c Derived class()d Sub class)9 The special syntax for invoking a constructor of the base class is:()a super()()b base()()c parent()()d child())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)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)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.).)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)14 The class __________ is an ancestor class of all Java classes.()a String()b Object()c Math()d JFrame)15 The Object class contains the method:()a getClass()()b toString()()c equals()()d all of the above)16 The equals method for a class should have _________ as the type of its one parameter.()a String()b Object()c Integer()d Double True/False)1 A derived class contains only public instance variables and public methods from the base class.)2 Inheritance refers to a very specialized form of a class.)3 A derived class is a class defined by adding instance variables and methods to an existing class.)4 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.)5 The keyword extends indicates polymorphism.)6 Overriding is when a derived class redefines a method from the base class.)7 A constructor for a derived class begins with an invocation of a constructor for the base class.)8 The call to the base class constructor (super) must always be the last action taken in a constructor definition.)9 You may substitute the keyword this for super() to call a constructor of the derived class.)10 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.)11 Private methods of the base class are not available for use by derived classes. Short Answer/EssayExplain what a call to super() does in a constructor of a derived class.Define a base class to represent a Clock. Your class should have instance variables for hours, minutes and seconds.Define a derived class to represent an alarm clock. Use the Clock class, created in number 2 above, as your base class.Create a test driver to test the functionality of your AlarmClock class created in number 3 above.Explain how parent and child classes are related to base and derived classes.Explain the difference between method overloading and method overriding.What is an “is a” relationship? How does it apply to the world of objects?)1 What is a “has a” relationship?)2 What is encapsulation?)3 Explain the modifiers public, protected and private.)4 What is package access?)5 Write Java statements that compares Objects, O1 and O2, using the getClass() method.)6 What does the instanceof operator do?)7 What are the different ways in which you can check the class of an Object?)8 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.)9 Create a test driver to test the functionality of your Rectangle class created in number 15 above.Chapter 7Inheritance 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)2 Inheritance promotes code ___________.()a reinvention()b reuse()c repeats()d all of the above)3 The keyword extends indicates:()a encapsulation()b polymorphism()c inheritance()d none of the above)4 A derived class is also called a()a sub class()b super class1()c base class()d all of the above)5 A super class is also called a()a derived class()b dominant class()c sub class()d base class)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)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.)8 A base class is synonymous with a:()a Child class()b Parent class()c Derived class()d Sub class)9 The special syntax for invoking a constructor of the base class is:()a super()()b base()()c parent()()d child())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)11 In using


View Full Document

SJU CSC 3405 - Inheritance

Download Inheritance
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Inheritance and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Inheritance 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?