Q1. By default, the visibility of data members in class is ?
Ans : private
Q2. What is class ?
Ans : Class is a user defined data type. It contains the data members and member functions. The access to the data members and functions of a class is controlled by use of three access-specifiers : public,protected and private. Class is declared with class keyword. We can have n objects of one class. Class provides the blueprint for its objects.
Q3. What is Object ?
Ans: Object is an instance of a class. Class provides the blueprint of data while objects are actually used to implement them. Memory is allocated for object only and not class. Objects are declared same as that of normal variables.
Q4. What is pointers ?
Ans: Pointer is an variable used to hold the memory address of the another variable or object.
Q5. What is full form of STL ?
Ans: Standard Template Library.
Q6. What is the difference between member function of class and normal function ?
Ans : The member function uses membership identity label in the header to indicate the class to which it belongs.While normal functions do not have such membership header.
Q7. How memory is allocated for data members and member functions of objects ?
Ans: The memory is allocated for objects when they are created. The separate memory space is allocated for member variables for different objects. But no separate space is allocated for member functions.
Q8. If protected member is inherited in public mode, its visibility in derived class is ?
Ans: Protected
Q9. If protected member is inherited in private mode, its visibility in derived class becomes ?
Ans: Private
Q10. What are the main features of OOP ?
Ans:Inheritance
Polymorphism
Encapsulation
Abstraction
Q11. What is Abstraction ?
Ans: Abstraction is a nothing but hiding the from end-user.For example language restricts the member access by private and protected members.
Q12. What is Inheritance ? Why to use Inheritance ?
Ans: The mechanism of deriving new class from existing old class is called inheritance.
The main purpose of using inheritance is the re-usability of code.
Q13. What is main difference between struct and class ?
Ans: The members of the structure are public by default whereas those of class are private by default.
Q14. Explain three access specifiers in C++.
Ans: private :The private members are accessible only within the same class.Even the class derived from it do not have access to private members.
public : Public members are accessible from anywhere.
protected : Only that class and its derived class have access to protected members.
Q15. How run-time polymorphism is achieved through virtual function ?
Ans: When we have the same function name in base and derived class, function in base class is declared as virtual. When function is made virtual, C++ determines which function to call at run-time depending upon the type of object pointed by base pointer. By making use of base pointer to points to different derived objects, we can execute different versions of virtual function. This is how run-time polymorphism is achieved.
Q16. What is Exception Handling?
Ans: When we write a snippet of code, we cannot ensure that it will work fine. It may misbehave at run run-time. Such misbehaviour is called as Exception. And the precaution taken to handle such exceptions is called exception handling.
Q17. List the types Inheritance.
Ans: Single Inheritance
Multiple Inheritance
Hierarchical Inheritance
Multilevel Inheritance
Hybrid Inheritance
Q18. What is the use of scope resolution operator (::) in class ?
Ans: Scope resolution operator is used to identify the class to which member function belongs.
Q19.The index of an array starts from
Ans: 0.
Q20. Can we have virtual constructors ?
Ans: No , we cannot have virtual constructors but can have virtual destructors.
Ans : private
Q2. What is class ?
Ans : Class is a user defined data type. It contains the data members and member functions. The access to the data members and functions of a class is controlled by use of three access-specifiers : public,protected and private. Class is declared with class keyword. We can have n objects of one class. Class provides the blueprint for its objects.
Q3. What is Object ?
Ans: Object is an instance of a class. Class provides the blueprint of data while objects are actually used to implement them. Memory is allocated for object only and not class. Objects are declared same as that of normal variables.
Q4. What is pointers ?
Ans: Pointer is an variable used to hold the memory address of the another variable or object.
Q5. What is full form of STL ?
Ans: Standard Template Library.
Q6. What is the difference between member function of class and normal function ?
Ans : The member function uses membership identity label in the header to indicate the class to which it belongs.While normal functions do not have such membership header.
Q7. How memory is allocated for data members and member functions of objects ?
Ans: The memory is allocated for objects when they are created. The separate memory space is allocated for member variables for different objects. But no separate space is allocated for member functions.
Q8. If protected member is inherited in public mode, its visibility in derived class is ?
Ans: Protected
Q9. If protected member is inherited in private mode, its visibility in derived class becomes ?
Ans: Private
Q10. What are the main features of OOP ?
Ans:Inheritance
Polymorphism
Encapsulation
Abstraction
Q11. What is Abstraction ?
Ans: Abstraction is a nothing but hiding the from end-user.For example language restricts the member access by private and protected members.
Q12. What is Inheritance ? Why to use Inheritance ?
Ans: The mechanism of deriving new class from existing old class is called inheritance.
The main purpose of using inheritance is the re-usability of code.
Q13. What is main difference between struct and class ?
Ans: The members of the structure are public by default whereas those of class are private by default.
Q14. Explain three access specifiers in C++.
Ans: private :The private members are accessible only within the same class.Even the class derived from it do not have access to private members.
public : Public members are accessible from anywhere.
protected : Only that class and its derived class have access to protected members.
Q15. How run-time polymorphism is achieved through virtual function ?
Ans: When we have the same function name in base and derived class, function in base class is declared as virtual. When function is made virtual, C++ determines which function to call at run-time depending upon the type of object pointed by base pointer. By making use of base pointer to points to different derived objects, we can execute different versions of virtual function. This is how run-time polymorphism is achieved.
Q16. What is Exception Handling?
Ans: When we write a snippet of code, we cannot ensure that it will work fine. It may misbehave at run run-time. Such misbehaviour is called as Exception. And the precaution taken to handle such exceptions is called exception handling.
Q17. List the types Inheritance.
Ans: Single Inheritance
Multiple Inheritance
Hierarchical Inheritance
Multilevel Inheritance
Hybrid Inheritance
Q18. What is the use of scope resolution operator (::) in class ?
Ans: Scope resolution operator is used to identify the class to which member function belongs.
Q19.The index of an array starts from
Ans: 0.
Q20. Can we have virtual constructors ?
Ans: No , we cannot have virtual constructors but can have virtual destructors.
0 Comments