What do you understand by procedural programming paradigm?
Ans: In the procedural Programming, program are divided into different procedures(also known as functions, routines or subroutines) and each procedure is a set of instruction is a set of instruction that performs a specific function.
What do you understand by object oriented programming paradigm?
Ans: In the Object Oriented Programming, programs are divided to represent real word models in a better way through object. The major concept in OOP includes objects, classes, encapsulation, abstraction, inheritance, and polymorphism.
Explain all the features of OOPs with their implementation in C++.
Encapsulation:
Enapsulation refers to the grouping of data and function within a single entity. The data and function that are encapsulated together correspond to the properties and action of the real word object respectively.
Data Hiding:
The data defined in the class accessed only through the function defined in the class Thus, the data is hidden and safe from any accidental modification or deletion by the program. This protection of the data from the class is known as data hiding or information hiding.
Inheritance:
Inheritance refers to the means by which one class acquires or inherits the data and function of another class. It allows the new class to have the same data and function of the existing class and add other the data and function specific to the new class.
Polymorphism:
Polymorphism refers to the ability of an operation to function in different ways depending on the context. Polymorphism is implemented either at compile time or at runtime. Functions are overloaded when they are defined with the same name but different parameters lists. The parameter list of the function differs from that of another function when the number or the data types of the parameters of the two functions differ.
Abstract Class:
A class which provides only the interface of one or more functions and not their implementations is known as an abstract class. An abstract class only specifies what the function does, what all its requires, etc. but it does not specify to the new class.
Concrete Class:
The class that provides an implementation for all its function is known as concrete class. The concrete class can have one or more object.
Why main function is so special in C++. Give at least two reasons.
Ans: Whenever a C++ program is executed only the main function is executed. The execution of the program starts and end at main().
Write two advantages of using #include complier directive.
Ans: #include directive instruct the compiler to include the contents of the file enclosed within angular brackets into the source file.
Illustrate the concept of function overloading with the help of an example.
Ans: Functions are overloaded when they are defined with the same name but different parameters lists. The parameter list of the function differs from that of another function when the number or the data types of the parameters of the two functions differ.
void add(int a,int b);
void add(int a,float b);
void add(int a,char str[ ]);
Why is a destructor function required in classes? Illustrate with the help of an example.
Ans: Destructor function is required because the resources and the memory allocated to data members must be released when the sope of the object terminates.