Assignment 2
Assignment 2
Assignment - 2
Deadline: 28 April 2025 (Monday)
Question 1:
What are destructors? How to differentiate them from constructors? Explain with the help of
an example.
Question 2:
Explain different types of inheritance with the help of examples.
(Single-level Inheritance, Multi-level Inheritance, Multiple Inheritance, Hierarchical
Inheritance and Hybrid Inheritance)
Question 3:
Explain Static members and Static member functions with examples.
Question 4:
i) Can an array be passed to a function by value or by reference? Explain.
ii) When a string is stored as a character array in C++, an additional byte is added at the
end. What is this extra byte, and what is its purpose?
Question 5:
Write a C++ program to design a base class Person (name, address, phone_no). Derive a
class Employee (eno, ename) from Person. Derive a class Manager (designation,
department name, basic-salary) from Employee. Write a menu driven program to:
i) Accept all details of 'n' managers
ii) Display manager having highest salary
Question 6:
An educational institution wishes to maintain a database of its employees. The database is
divided into a number of classes whose hierarchical relationships are shown in Figure. The
figure also shows the minimum information required for each class. Specify all the classes
and define functions to create the database and retrieve individual information as and when
required.
Question 7:
Assume that a bank maintains two kinds of accounts for customers, one called as savings
account and the other as current account. The savings account provides compound interest
and withdrawal facilities but no cheque book facility. The current account provides cheque
book facility but no interest. Current account holders should also maintain a minimum
balance and if the balance falls below this level, a service charge is imposed.
Create a class account that stores customer name, account number and type of account.
From this, derive the classes cur_acct and sav_acct to make them more specific to their
requirements. Include necessary member functions in order to achieve the following tasks:
Do not use any constructors. Use member functions to initialize the class members.
Question 8:
How to use the following keywords? Demonstrate with the help of an example.
i) new
ii) delete
Question 9:
What are the 3 methods to call members and member functions for an object pointer? Give
examples.
Question 10:
How to create an array of pointers and how to use them? Elaborate.
Question 11:
Justify whether the following function declarations are same or different.
Question 12:
Difference between Reference Variable and Pointer.
Question 13:
Difference between Function Overriding and Function Overloading.