1. Which of the following is not a keyword in C++?

A) private

B) protected

C) friend

D) global

Answer: D) global

2. Which is the Header file for cin and cout in C++?

A) iostream

B) cstdio

C) cmath

D) cstdlib

Answer: A) iostream

3. Which one will not throw an exception for the dynamic memory in C++?

A) malloc()

B) new

C) alloc()

D) malloc()

Answer: B) new

4. What is the size of a double data type in C++ on a 64-bit system?

A) 4 bytes

B) 8 bytes

C) 2 bytes

D) 16 bytes

Answer: B) 8 bytes

5. What is the definition of a pointer which will point to integer in c++ code?

A) int *ptr;

B) int &ptr;

C) ptr int*;

D) *int ptr;

Answer: A) int *ptr;

6. Single line Comment in C++

A) // Comment

B) /* Comment */

C) ** Comment

D) # Comment

Answer: A) // Comment

7. Output is — What will be the output of the above code?

int a = 5;
cout << ++a;

A) 4

B) 5

C) 6

D) Compilation error

Answer: C) 6

8. This loop certainly makes sure that the block of code will be executed… once.

A) for loop

B) while loop

C) do-while loop

D) All of the above

Answer: C) do-while loop

9. Output of the above code

for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
cout << i << j;
}
}

A) 00011021

B) 010201

C) 001102

D) 011020

Answer: A) 00011021

10. Which among the following is a correct C++ way for declaring an array

int arr[5] = {1, 2, 3, 4,5};

B) arr(5) int{1, 2, 3,4,5};

C )arr[5] int ={1, 2,3…4 h);}

D) int[] arr = {1, 2, 3​ D}

Ans A): int arr[5] = {1, 2,3,4,5};

11. What does the following C++ code output?

int a = 5, b = 2;
int c = a / b;
cout << c;

A) 2.5

B) 2

C) 3

D) 0

Answer: B) 2

12. OOP — How to Think Like a Programmer

A) Inheritance is not one of the pillars in Object-Oriented Programming (OOP)$_$

A) Inheritance

B) Encapsulation

C) Polymorphism

D) Abstraction

Answer: D) Abstraction

13. So the question will be how we can make a derived class to inherit the base class and its properties in Object Oriented Programming?

A) Encapsulation

B) Inheritance

C) Polymorphism

D) Data hiding

Answer: B) Inheritance

14. Class Declaration in C++

A) class MyClass { };

B) MyClass class { };

C) object MyClass { };

D) structure MyClass { };

Answer: A) class MyClass { };

15. protected hidden the class member but that can be acessed in derived classes only.

A) private

B) protected

C) public

D) static

Answer: B) protected

16. A constructor is used to do the basic job and most of them have some functionality in common.

A) To destroy an object

B) To initialize an object

C) To inherit properties

D) To overload operators

Answer: B) Create an Object

17. Explain the Major Difference Between Constructor and Destructor In C++ Concerning IOT.

A) Desructor Destroy Object, Constructor Create it.

B) Constructor initializes an object or constructs an object whereas Destructor is some clean up after the destruction of any object.

C) Constructor is private and Destructor is public.

D) Constructor can not be overloaded and it also have multiple definition of the constructor.

Answer: B) Constructor initializes an object or constructs an object whereas Destructor is some clean-up after the destruction of any object.

18. Which of the following is correct about constructors in C++?

A) Constructor with return type.

B) Constructors Overloading

C) No argument constructors

D)A constructor must be virtual.

Answer: B) Constructors Overloading

B) Constructors can be overloaded. Answer: B_BUILD UPON Explanation:- Option-D is incorrect because D) Constructor cannot have exceptions in its specification Caseisthebest_BITM_061_BASICACEMENT_WRONG

19. Is that the polymorphism in c++?

A) Overloading

B) Inheritance

C) Encapsulation

D) Abstract class

Answer: A) Overloading

Inheritance and Virtual Functions in C++IllegalAccessException How can we implement Inheritance using the Advanced OOP concept introduced by Other…medium.com Reverse Learn Python — Middle #5-Advanced...

20. If a class can inherit from more than one base class, what type of inheritance is this?

A) Single inheritance

B) Multilevel inheritance

C) Multiple inheritance

D) Hierarchical inheritance

Answer: C)Multiple inheritance

21. Write the keyword that is used in C++ for the declared Virtual function?

A) virtual

B) override

C) inherit

D) base

Answer: A) virtual

22. Output

class Base {
public:
virtual void show() { court
<< “Base”; } }; class Derived : public Base { public: void show() { court << “Derived”; } }; int main() { Base *b; Derived d; b = &d; b->show();
}

A) Base

B) Derived

C) Compilation error

D) No output

Answer: B) Derived

23. Which of the following statement(s) is/are true regarding destructors. 1).

A) class can have multiple destructors in the following sense.

B) You can not invoke destructors, but they are called automatically.

C) Destructores are type devoid & cannot be passed arguments.

D) Overloading of Destructors

Answer: C) Destructores are type devoid & cannot be passed arguments.

24. This is a common issue with virtual functions, and the main trouble shooting options are listed below; Which of these answers IS NOT correct for this problem A

Dynamic — this is how you achieve dynamic polymorphism.

A) Compile Time Virtual Functions resolution

B) Virtual functions are resolved at compile-time.

C) Virtual functions should be declared in one base-class of the derived class. →

D) Virtual function calls are resolved at the compile time.

Answer: B) Virtual functions are resolved at compile-time.

Scroll to Top