Technical Interview Questions and Answers :: C++
Classes are user defined data types and behave like the built-in type of a programming language. The wrapping up of data and functions into a single unit called class.
Objects are the basic run-time entities in an object-oriented system. When a program is executed, the objects interact by sending messages to one another.
Yes, struct is similar to class, only all attributes/methods are public by default in the struct. You can very well have methods and attributes in a struct. You can also inherit from a struct (default inheritance is public).
Yes, Size of an empty class is not zero. It is 1 byte generally. It is nonzero to ensure that the two different objects will have different addresses.
Protected access specifier makes the method accessible only by the derived class.
Mutable storage class is applicable to only class data members. If a data member of a class is declared as mutable, then it can be modified by an object which is declared as constant.
An array is a contiguous chunk of memory with a fixed size whereas a list is typically implemented as individual elements linked to each other via pointers and does not have a fixed size. Once an array is initialized, it cannot be resized, and it uses a fixed amount of memory regardless of how much stuff you put in it. Since a list is a collection of individual chunks of memory that are dynamically allocated, the space required to store a list is directly related to the number of elements in it.
When a method is declared as abstract/virtual method in a base class and which is overridden in a base class. If we create a variable of a type of a base class and assign an object of a derived class to it, it will be decided at a run time, which implementation of a method is to be called.
This is known as Pure-Polymorphism or Late-Binding.
This pointer is called current object of the class.
You can check latest and updated C++ Exam Questions C++ Exam Questions and Answers on this page. You can filter the question set by the company's name. Looking for the right answer? Don't worry! You can click on view answer section and check the answer with the explanation. You can discuss the answer in the forum with other users easily. Login with Facebook and save the answer To Reading List right now!
Our site contains top IT companies placement paper and mock test to help the freshers and experienced candidate to get hands on experience on the pattern and type of questions. We have curated all the C++ technical interview questions and answers from previous candidates.