Practice Sheet
Practice Sheet
1. Single Inheritance:
Question: Create a base class Person with attributes name and age. Derive a class
Student that has an additional attribute grade. Write a program to input and display
student details.
Variables:
o name (string)
o age (int)
o grade (char)
2. Multilevel Inheritance:
Question: Create a base class Animal with an attribute species. Derive a class
Mammal with an attribute furColor. Further, derive a class Dog with an attribute
breed. Write a program to input and display dog details.
Variables:
o species (string)
o furColor (string)
o breed (string)
3. Multiple Inheritance:
Question: Create a class Engine with an attribute horsepower. Create another class
Wheels with an attribute numWheels. Derive a class Car from both and add an
attribute brand. Write a program to input and display car details.
Variables:
o horsepower (int)
o numWheels (int)
o brand (string)
4. Hierarchical Inheritance:
Question: Create a base class Employee with attributes empID and name. Derive two
classes Manager and Developer. Manager has an additional attribute teamSize, and
Developer has programmingLanguage. Write a program to input and display details.
Variables:
o empID (int)
o name (string)
o teamSize (int)
o programmingLanguage (string)
5. Hybrid Inheritance:
Question: Create a class Device with attribute deviceName. Derive two classes
Computer and Mobile. Further, derive a class Smartphone from both Computer and
Mobile. Write a program to display details of a smartphone.
Variables:
o deviceName (string)
o processor (string)
o batteryLife (int)
o radius (double)
o length (double)
o width (double)
o salary (double)
o hoursWorked (int)
o ratePerHour (double)
brand (string)
powerConsumption (int)
accountNumber (int)
balance (double)
interestRate (double)
model (string)
year (int)
engineType (string)
title (string)
author (string)
genre (string)
14. Employee Management:
Question: Create a base class Employee with attributes empID and salary. Derive
Manager, Engineer, and Intern with specific methods.
Variables:
empID (int)
salary (double)
department (string)
name (string)
rollNumber (int)