0% found this document useful (0 votes)
6 views1 page

Inheritance Assignment

Uploaded by

aribasial50
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Inheritance Assignment

Uploaded by

aribasial50
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Conceptual / Coding Questions

1. Basic Inheritance:
Write a program where a Person class contains attributes like name and age. Create a
derived class Student that adds attributes like rollNo and marks. Demonstrate how a
student object can access both parent and child attributes.
2. Constructor in Inheritance:
Create a Vehicle class with attributes company and model. Derive a class Car with
attributes fuelType and seatingCapacity. Show how constructors are invoked in base
and derived classes.
3. Method Overriding:
Design a Shape class with a method area(). Derive classes Rectangle and Circle, each
overriding the area() method. Write a program to calculate area of both shapes using
base class references.
4. Access Specifiers in Inheritance:
Demonstrate the use of public, private, and protected inheritance with a
BankAccount class (attributes: accountNumber, balance) and a derived class
SavingsAccount. Show which members are accessible in the derived class and outside.
5. Multilevel Inheritance:
Write a program with Animal → Mammal → Dog hierarchy. Each class should add one
unique behavior. Show how a Dog object can call methods from all three classes.

Applied / Problem-Solving Questions

6. Hierarchical Inheritance:
Create a Publication class with attributes title and price. Derive two classes: Book
(with pageCount) and Magazine (with issueNumber). Write a program to input and
display data of books and magazines.
7. Hybrid Inheritance (using Interfaces / Multiple Inheritance simulation):
Implement a program where a class Scanner inherits features from both Printer and
Device. Use abstract classes or interfaces (depending on the language) to handle multiple
inheritance.
8. Polymorphism through Inheritance:
Create a Payment class with a method processPayment(). Derive CreditCardPayment
and PayPalPayment classes overriding the method. Write a program to process payments
polymorphically using base class pointers/references.
9. Real-Life Case Study:
Implement a LibraryMember class (name, memberId). Derive two classes:
StudentMember (maxBooksAllowed = 3) and FacultyMember (maxBooksAllowed =
10). Demonstrate how rules differ for both members when borrowing books.
10. Inheritance with Data Validation:
Design a Product class (id, name, price). Derive a class DiscountedProduct that adds a
discount percentage. Ensure that discount cannot exceed 50%. Write methods to calculate
and display final price.

You might also like