• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

CPlusPlus Interview Questions Answers

Question - 51 : - What does extern mean in a function declaration?

Answer - 51 : - It tells the compiler that a variable or a function exists, even if the compiler hasn’t yet seen it in the file currently being compiled. This variable or function may be defined in another file or further down in the current file.

Question - 52 : - What do you mean by pure virtual functions?

Answer - 52 : - A pure virtual member function is a member function that the base class forces derived classes to provide. Normally these member functions have no implementation. Pure virtual functions are equated to zero. class Shape { public: virtual void draw() = 0; };

Question - 53 : - What is polymorphism? Explain with an example?

Answer - 53 : - "Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or reference) to assume (be replaced by) or become many different forms of object. Example: function overloading, function overriding, virtual functions. Another example can be a plus ‘+’ sign, used for adding two integers or for using it to concatenate two strings.

Question - 54 : - Describe Stacks and name a couple of places where stacks are useful.

Answer - 54 : - A Stack is a linear structure in which insertions and deletions are always made at one end, called the top. This updating policy is called last in, first out (LIFO). It is useful when we need to check some syntex errors, such as missing parentheses.

Question - 55 : - Does c++ support multilevel and multiple inheritance?

Answer - 55 : - Yes.

Question - 56 : - What do you mean by binding of data and functions?

Answer - 56 : - Encapsulation.

Question - 57 : - In the derived class, which data member of the base class are visible?

Answer - 57 : - In the public and protected sections.

Question - 58 : - Explain differences between eg. new() and malloc()

Answer - 58 : - 1. 1.) “new and delete” are preprocessors while “malloc() and free()” are functions. [we dont use brackets will calling new or delete]. 2.) no need of allocate the memory while using “new” but in “malloc()” we have to use “sizeof()”. 3.) “new” will initlize the new memory to 0 but “malloc()” gives random value in the new alloted memory location [better to use calloc()] 2. new() allocates continous space for the object instace malloc() allocates distributed space. new() is castless, meaning that allocates memory for this specific type, malloc(), calloc() allocate space for void * that is cated to the specific class type pointer.

Question - 59 : - Is C an object-oriented language?

Answer - 59 : - C is not an object-oriented language, but limited object-oriented programming can be done in C.

Question - 60 : - What is the need for a Virtual Destructor ?

Answer - 60 : - 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.

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners