Vidyalelo
C++ Programming · all questions

Object Oriented Programming in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

80

Questions

3/4

Page

Pick an option on a question to see the right answer and solution.

What is the default access specifier for members of a class in C++?

Select an option to see the answer and solution.

Which keyword is used to make a class inheritable by other classes in C++?

Select an option to see the answer and solution.

What is the purpose of destructors in C++?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include<iostream> 
using namespace std; 
class Base { 
public: 
	Base()	 
	{ cout<<"Constructing Base \n"; } 
	virtual~Base() 
	{ cout<<"Destructing Base \n"; }	 
}; 
class Derived: public Base { 
public: 
	Derived()	 
	{ cout<<"Constructing Derived \n"; } 
	~Derived() 
	{ cout<<"Destructing Derived \n"; } 
}; 
 
int main(void) 
{ 
	Derived *d = new Derived(); 
	Base *b = d; 
	delete b; 
	return 0; 
}

Select an option to see the answer and solution.

Which concept allows you to reuse the written code?

Select an option to see the answer and solution.

What is virtual inheritance?

Select an option to see the answer and solution.

How structures and classes in C++ differ?

Select an option to see the answer and solution.

Which of the following class allows to declare only one object of it?

Select an option to see the answer and solution.

Which of the following is correct about new and malloc?
i. new is an operator whereas malloc is a function
ii. new calls constructor malloc does not
iii. new returns required pointer whereas malloc returns void pointer and needs to be typecast

Select an option to see the answer and solution.

How run-time polymorphisms are implemented in C++?

Select an option to see the answer and solution.

Out of the following, which is not a member of the class?

Select an option to see the answer and solution.

What is the correct syntax of declaring array of pointers of integers of size 10 in C++?

Select an option to see the answer and solution.

Which of the following explains Polymorphism?

Options are not available for this question.

Select an option to see the answer and solution.

Which of the following feature of OOPs is not used in the following C++ code?
class A
{
    int i;
    public:
    void print(){cout<<"hello"<<i;}
}
 
class B: public A
{
    int j;
    public:
    void assign(int a){j = a;}
}

Select an option to see the answer and solution.

Why references are different from pointers?

Select an option to see the answer and solution.

Which of the following explains the overloading of functions?

Select an option to see the answer and solution.

What is the difference between delete and delete[] in C++?

Select an option to see the answer and solution.

Which of the following is correct?

Select an option to see the answer and solution.

What is the other name used for functions inside a class?

Select an option to see the answer and solution.

Which of the following is an abstract data type?

Select an option to see the answer and solution.