1: pure virtual construction can have a body
ans - FALSE . there is no such entity as pure virtual constructor .even if we were allowed to declare a pure virtual constructor , we would not be able to override it.
2: there is one VPTR per VTABLE
answer: - FALSE . this is because each object contains VPTR in it
3: there is one VPTR per object
Answer : True But all the object has the same VPTR
4: The VPTR always points to the VTABLE of the class
answer - true;
5: virtual functions permit functions from different classses to be executed through the same function call
answer:- True. This is one form of polymorphism .
6: A class containing a pure virtual function is called
ans- Abstract class
7: virtual function calls work faster than normal function calls
ans: false . This is because the call to the virtual function is resolved at runtime . Moreover the call is resolved after retrieving the address of the function from the VTABLE . Thus it conumes time
The call to the normal function is resolved at compile time also there is no mechnaism of VTABLE involved in calling the normal function
8: virtual functions can be safely invoked using objects
ans: TRUE
9: The behaviour of virtual functions is same irrespective of whether we invoke them through pointers or references;
answer - TRUE
10: A pure virtual destructor can have a function body
ANS - False . There is no such concept of pure pure virtual destructor in c++
11: The virtual function of a a base class that is overridden in the derived class also becomes virtual
Ans true;
12 : An abstract class typically doesn't need a constructor
ans: TRUE, since we cannot instantiate an object from an abstract class there is not need to constructor in that class
13 : how many VTABLE will be in class
ANS: one ;
14 : can be access the VTABLE using the this pointer;
ans : true ,we can access the vatable using 'this' pointer ;
15: What is VPTR
ANS: The address of the VTABLE stored in the object is known as VPTR

0 comments:
Post a Comment