Technical Interview Questions and Answers :: C++
11. What are the difference between an object and a class?| | |
12. What do you mean by binding of data and functions?| | |
13. Can we implement all the concepts of OOPS using the keyword struct?| | |
14. What is the difference between class and structure?| | |
15. Can we create an empty class? If so what would be the sizeof such object.| | |
16. What are the role of protected access specifier?| | |
17. What are the role of mutable storage class specifier?| | |
18. What are the difference between an ARRAY and a LIST?| | |
19. What is polymorphism and Pure-Polymorphism?| | |
20. What is "this" pointer?| | |
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.
The member functions of every object have access to a sort magic pointer named this, which points to the object itself. Thus any member function can find out the address of the object of which is a member.
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.