CS Electrical And Electronics
@cselectricalandelectronics
All PostsCPPInterview QuestionsProgramming

Cpp Interview Questions, Object-Oriented Programming Questions

Hello guys, welcome back to my blog. In this article, I will discuss Cpp interview questions, object-oriented programming interview questions asked during interviews, OOPs interview questions, etc.

If you have any doubts related to electrical, electronics, and computer science, then ask question. You can also catch me @ Instagram – Chetan Shidling. 

Also, read:

Cpp Interview Questions

01. Explain object oriented programming. Differentiate between procedure oriented and object oriented programming?

02. Explain the features of object oriented programming?

03. List out the basic concepts of OOPs. Explain Objects and Classes?

04. With neat diagram, explain the basic idea of Inheritance and Polymorphism?

05. Explain the benefits of OOPs?

06. Write a C++ program to read two numbers and display sum on the screen. Explain with a neat diagram, how input and output operators are used in the above program?

07. Write a C++ program to define a class to read name and age of a person and display them on screen?

08. Write a C++ program to read the a, b and c and display the value of x, where, x = a/b-c. Test your program for different input values?

09. Explain the benefits of using classes in C++ over the limitations of structures in C?

10. Write a C++ program to demonstrate creation of class, objects and how do you access the members of a class using objects. Explain each section?

11. Explain how member functions are defined for a class. Demonstrate with a C++ program?

12. Explain how member functions are defined for a class. Demonstrate with a C++ program?

13. Design and implement a C++ code to access the data members and member functions in the following cases:\n\n inside main program\n inside a member function of same class\n?

14. Design and implement a C++ code to access the data members and member functions in the following cases:\n\n inside main program\n inside a member function of same class\n?

15. Explain the output of this program?

#include<iostream.h>
using namespace std;
class sample { int x; }
int main() {sample obj; obj.x=100; cout<<“x=”<<obj.x<<endl;}

16. Write C++ program to read time in HH:MM:SS format and convert into total seconds using class?

17. Write C++ program to create student class, read and print N student\’s detials (Use array of objects)?

18. Explain the use of scope resolution operator in C++? Give an example?

19. Define static data members and static member functions. Explain use of both with a simple C++ program?

20. Write a C++ program to demonstrate the use of inline and friend functions?

21. Define constructor. How to use constructors in C++ programs. Demonstrate with the help of C++ program?

22. Explain the role of a default constructor? When is it considered equivalent to a parameterized constructor? Support your answer with examples?

23. Explain parameterized constructor? How is it useful?

24. Differentiate between a default constructor and copy constructor, giving suitable examples of each?

25. A bookshop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displays whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the system displays the book details and requests for the number of copies required. If the requested copies are available, the total cost of the required copies is displayed, otherwise the message “Sorry! These many copies are not in stock” is displayed. Design a system using a class called stock with suitable member functions and constructors.

26. Describe the importance of destructor using a C++ program. List some of the special properties of destructor?

27. Write a C++ program to store GPA of n number of students and display it, where n is the number of students entered by user. Use new and delete operators?

28. Write a C++ program to demonstrate how to dynamically create single or multiple objects?

29. Define smart pointer. Justify, how smart pointer is different from delete operator?

30. Define Exception. Explain how exceptions are handled in C++?

31. Discuss the advantages of using exception handling mechanisms in a program?

32. Explain when a catch(…) handler is used?

33. Explain try/catch block to handle arithmetic exceptions?

34. Write a C++ program to demonstrate the concept of rethrowing an exception?

35. Write a C++ program that illustrates the application of multiple catch blocks?

36. Explain Inheritance. List and explain with neat diagram, the different types of Inheritances in C++ programming?

37. Explain the syntax of following inheritances in C++ single inheritance, multiple inheritance, hierarchical inheritance?

38. Explain the virtual base class. When do we make a class virtual. Justify with the help of program?

39. Define abstract classes. Write a C++ program to demonstrate the use of abstract classes in C++?

40. Class D is derived from class B, class D does not contain any of its data members. Does class D require constructors? Justify.

41. Write and explain the C++ program to demonstrate the use of constructor in: multiple inheritance and multilevel inheritance?

42. Explain nesting of classes in C++. Explain the way of nesting of two classes (class beta and class gamma) inside first class (class alpha). Demonstrate with C++ program?

43. Define pointer and this pointer. What does this pointer point to?

44. List the applications of this pointer?

45. Explain how a pointer can point to an object created by a class?

46. Explain pointers to derived class?

47. Explain virtual functions and list the rules for virtual functions?

48. Explain when to make a virtual function “pure”?

49. True or false: A pointer to a base class can point to objects of a derived class?

50. Explain constructor overloading?

51. Discuss the usage of function overloading?

52. Discuss how a function is different from an overloaded function?

53. Explain operator overloading and list the restrictions and limitations of operator overloading?

54. Write a C++ program to demonstrate the concept of Unary operator?

55. Write a C++ program to demonstrate the concept of binary operator?

56. Write a C++ program to demonstrate the concept of function overloading?

57. Write a C++ program to demonstrate the concept of constructor overloading?

58. Create a class FLOAT that contains one float data member. Overload all the four arithmetic operators so that they operate on the objects of FLOAT?

59. Explain generic programming and how it is implemented in C++?

60. Differentiate between overloaded function and function templates?

61. Write C++ program to display largest among two numbers using function templates?

62. Write C++ program to add, subtract, multiply and divide two numbers using class template?

63. Define STL is C++. Explain the core components of STL?

64. What are containers in C++. Explain the containers supported by C++?

65. Write a C++ program to demonstrate use of vector class?

66. Define and explain iterators and its characteristics?

67. What are the different modes of inheritance?

68. What is private mode inheritance in Cpp?

69. What is protected mode inheritance in Cpp?

70. What is public mode inheritance in Cpp?

71. What is Compile time Polymorphism in Cpp?

72. What is Runtime Polymorphism in Cpp?

73. Difference between global and local variable?

74. What is Encapsulation?

75. What is inline function and why it is used?

76. What is friend function and why it is used?

I hope this article “Cpp Interview Questions” may help you all a lot. Thank you for reading “Cpp Interview Questions”.

Also, read:

Author Profile

CS Electrical And ElectronicsChetu
Interest's ~ Engineering | Entrepreneurship | Politics | History | Travelling | Content Writing | Technology | Cooking
Share Now

CS Electrical And Electronics

Interest's ~ Engineering | Entrepreneurship | Politics | History | Travelling | Content Writing | Technology | Cooking

Leave a Reply

Your email address will not be published. Required fields are marked *