Inheritance and Polymorphism in Object-Oriented Programming
16 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What does inheritance create in object-oriented programming?

  • A 'uses a' relationship among classes
  • A 'has a' relationship among classes
  • A 'is a' relationship among classes (correct)
  • A 'belongs to' relationship among classes

What kind of characteristics does a specialized object have in relation to the general object?

  • Subset of the characteristics of the general object
  • Opposite characteristics
  • Similar characteristics
  • All of the characteristics of the general object, plus additional special characteristics (correct)

Which term best describes the relationship between a post graduate student and a student?

  • Generalization
  • Specialization (correct)
  • Aggregation
  • Encapsulation

What term describes the relationship between an employee and a person?

<p>'Is a' relationship (A)</p> Signup and view all the answers

Which relationship can be extended through inheritance in object-oriented programming?

<p>'Is a' relationship (B)</p> Signup and view all the answers

What is the purpose of inheritance in object-oriented programming?

<p>To create reusable classes with shared characteristics (D)</p> Signup and view all the answers

What is the term used for the relationship between a superclass and a subclass?

<p>Parent-child relationship (C)</p> Signup and view all the answers

Which keyword is used in Java to define a subclass?

<p>extends (D)</p> Signup and view all the answers

What happens to private members of the superclass in a subclass?

<p>They are not inherited by the subclass (D)</p> Signup and view all the answers

Which keyword refers to an object's superclass in Java?

<p>super (C)</p> Signup and view all the answers

When a subclass is instantiated, which constructor is executed first?

<p>Superclass default constructor (B)</p> Signup and view all the answers

What must be the first Java statement in a subclass constructor when calling a superclass constructor?

<p><code>super</code> keyword (C)</p> Signup and view all the answers

What is it called when a subclass method has the same signature as a superclass method?

<p><code>Method overriding</code> (C)</p> Signup and view all the answers

Which annotation should be used before a subclass method declaration to indicate method overriding?

<p>@Override (B)</p> Signup and view all the answers

In a Salaried Employee class, how can the get_salary() method be modified to override the superclass method?

<p><code>public double get_salary() { return salary + bonus - deductions ; }</code> (A)</p> Signup and view all the answers

What happens to constructors when a subclass is instantiated?

<p><code>Superclass default constructor is executed first</code> (C)</p> Signup and view all the answers

More Like This

Use Quizgecko on...
Browser
Browser