Exam 10: Introduction to Inheritance

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

How are real-life examples of inheritance similar to object-oriented programming inheritance?

Free
(Essay)
4.8/5
(47)
Correct Answer:
Verified

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?

Free
(Essay)
4.9/5
(30)
Correct Answer:
Verified

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.

Free
(Multiple Choice)
4.9/5
(38)
Correct Answer:
Verified

D

In a UML diagram, an inheritance relationship is indicated with an arrow that points from the original class  to the descendant class .

(True/False)
4.8/5
(45)

When you employ ____, your data can be altered only by the methods you choose and only in ways that you can control.

(Multiple Choice)
4.8/5
(44)

Which statement correctly declares a sedan object of the Car class?

(Multiple Choice)
4.8/5
(37)

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.

(Multiple Choice)
4.8/5
(34)

An error is generated by the compiler when you attempt to override a static method with a nonstatic method.

(True/False)
4.8/5
(37)

Subclasses are more specific than the superclass they extend.

(True/False)
4.8/5
(33)

In Java, all instance method calls are ____ by default.

(Multiple Choice)
4.9/5
(36)

Using a class named Student , write the statement to create a yearOne object of the Student class.

(Short Answer)
4.8/5
(32)

When you create any subclass object, the subclass constructor  must execute first, and then the superclass constructor  executes.

(True/False)
4.8/5
(29)

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.

(Multiple Choice)
4.8/5
(25)

____ polymorphism is the ability of one method to work appropriately for subclasses of the same parent class.

(Multiple Choice)
4.8/5
(41)

What happens when you write your own constructor in Java and what must you pay attention to?

(Essay)
4.8/5
(37)

  The above code will generate an error message when compiling. Explain the error message and why it occurs. The above code will generate an error message when compiling. Explain the error message and why it occurs.

(Essay)
4.8/5
(38)

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.

(True/False)
4.7/5
(31)

What is the process of inlining and how is it accomplished in Java?

(Essay)
4.7/5
(34)
Match each term with the correct statement below.
Premises:
Graphical language used to describe classes and methods
Responses:
information hiding
inheritance
fragile
Correct Answer:
Verified
Premises:
Responses:
Graphical language used to describe classes and methods
information hiding
(Matching)
4.8/5
(37)

You are never aware that ____ is taking place; the compiler chooses to use this procedure to save the overhead of calling a method.

(Multiple Choice)
4.8/5
(32)
Showing 1 - 20 of 78
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)