Question 16 :
What methods can be overridden in Java?
In C++ terminology, all public methods in Java are virtual. Therefore, all Java methods can be overwritten in subclasses except those that are declared final, static, and private.
Question 17 :
What are the defining traits of an object-oriented language?
The defining traits of an object-oriented langauge are:
Question 18 :
What is the need for a Virtual Destructor ?
Destructors are declared as virtual because if do not declare it as virtual the base class destructor will be called before the derived class destructor and that will lead to memory leak because derived classâ€™s objects will not get freed.Destructors are declared virtual so as to bind objects to the methods at runtime so that appropriate destructor is called.
Question 19 :
Differences of C and C++
Could you write a small program that will compile in C but not in C++ ?
In C, if you can a const variable e.g.
const int i = 2;
you can use this variable in other module as follows
extern const int i;
C compiler will not complain.
But for C++ compiler u must write
extern const int i = 2;
else error would be generated.
Question 20 :
Bitwise Operations - Given inputs X, Y, Z and operations | and & (meaning bitwise OR and AND, respectively), what is output equal to in?
(X & Y) | (X & Z) | (Y & Z);