Short Answer type Questions on C/C++ Language

1. What are abstract classes?
Classes containing at least one pure virtual function become abstract classes. Classes inheriting abstract classes must redefine the pure virtual functions; otherwise the derived classes also will become abstract. Abstract classes cannot be instantiated.

2. Define abstraction and Encapsulation.
Abstraction refers to the act of representing the essential features without including the background details or explanations.The wrapping up of data and functions into a single unit is known as data encapsulation.

3. What is the Need for Static Members.
Class members can be declared using the storage class specifier static in the class member list. Only one copy of the static member is shared by all objects of a class in a program. When you declare an object of a class having a static member, the static member is not part of the class object.

4. Define Polymorphism.
Polymorphism is another important oops concept. Polymorphism means the ability to take more than one form. For example, an operation may exhibit different behavior in different instances. Behavior depends upon the types of data used in the operation.

5. What do you mean by pure virtual functions?
A pure virtual member function is a member function that the base class forces derived classes to provide. Any class containing any pure virtual function cannot be used to create object of its own type.

6. What is function Prototype? 
A function prototype or function interface in C, Perl, PHP or C++ is a declaration of a function that omits the function body but does specify the function's return type, name and argument types. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.

7. What is an identifier?
Identifiers are names for various programming elements in c++ program. such as variables, arrays, function, structures, union, labels ect., An identifier can be Composed only of uppercase, lower case letter, underscore and digits, but should start only with an alphabet or an underscore.

8. What is a keyword?
Keywords are word whose meanings have been already defined in the c compiler. They are also called as reserved words. For example main(), if, else, else, if, scanf, printf, switch, for, goto, while ect.,

9. Define data hiding.
The purpose of the exception handling mechanism is to provide a means to detect and report an “exceptional circumstance” so that appropriate action can be taken.

10. What is the use of scope resolution operator?
In C, the global version of the variable cannot be accessed from within the inner block. C++ resolves this problem by introducing a new operator :: called the scope resolution operator. It is used to uncover a hidden variable.Syntax: :: variable_name

11. When will you make a function inline?
When the function definition is small, we can make that function an inline function and can mainly go for inline function to eliminate the cost of calls to small functions.

12. What is overloading?

Overloading refers to the use of the same thing for different purposes. There are 2 types of overloading:
1. Function overloading
2. Operator overloading

13. What is the difference between normal function and a recursive function?
A recursive function is a function, which call it whereas a normal function does not. Recursive function can’t be directly invoked by main function.

Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment: