Exam 10: Introduction to Inheritance
How are real-life examples of inheritance similar to object-oriented programming inheritance?
You might choose plants and animals based on inheritance. You plant impatiens next to your house because of your shady street location; you adopt a Doberman Pinscher because you need a watchdog. Every individual plant and pet has slightly different characteristics; but within a species, you can count on many consistent inherited attributes and behaviors. Similarly, the classes you create in object-oriented programming languages can inherit data and methods from existing classes. When you create a class by making it inherit from another class, you are provided with data fields and methods automatically.
When you instantiate an object that is a member of a subclass, how many constructors are called?
When you instantiate an object that is a member of a subclass, you are actually calling at least two constructors: the constructor for the base class and the constructor for the extended, derived class. When you create any subclass object, the superclass constructor must execute first, and then the subclass constructor executes.
If a programming language does not support ____, the language is not considered object-oriented.
D
In a UML diagram, an inheritance relationship is indicated with an arrow that points from the original class to the descendant class .
When you employ ____, your data can be altered only by the methods you choose and only in ways that you can control.
Which statement correctly declares a sedan object of the Car class?
Sometimes the superclass data fields and methods are not entirely appropriate for the subclass objects; in these cases, you want to ____ the parent class members.
An error is generated by the compiler when you attempt to override a static method with a nonstatic method.
Using a class named Student , write the statement to create a yearOne object of the Student class.
When you create any subclass object, the subclass constructor must execute first, and then the superclass constructor executes.
If a ____ method has the same name as a parent class method and you use the name with a child class object, the child method hides the original.
____ polymorphism is the ability of one method to work appropriately for subclasses of the same parent class.
What happens when you write your own constructor in Java and what must you pay attention to?
The above code will generate an error message when compiling. Explain the error message and why it occurs.

When a protected data field or method is created, it can be used within its own class or in any classes extended from that class; but it cannot be used by outside classes.
You are never aware that ____ is taking place; the compiler chooses to use this procedure to save the overhead of calling a method.
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)