https://res.cloudinary.com/hg6hswtwo/image/upload/v1/media/pics/oop_toolsandjobs_se2jyx_ehsslg
secondyear

Polymorphism & Inheritance MCQs in OOP For Exams Part 4





Polymorphism & Inheritance MCQs in OOP For Exams Part 4. 

click here for part-3 MCQ

1 When deriving a class with public inheritance, public members of the base class become
__________ members of the derived class, and protected members of the base class
become ___________members of the derived class.
A private, private
B public, protected.
C protected, protected.
D private, protected

Answer B

2 C++ provides for ________________, which allows a derived class to inherit from many
base classes, even if the base classes are unrelated.
A Multilevel inheritance
B Single level inheritance
C multiple inheritance
D Hierarchical inheritance

Answer C

3 __________________is a form of software reuse in which new classes absorb the data
and behaviors of existing classes and embellish these classes with new capabilities.
A Data hiding
B Inheritance
C Abstraction
D encapsulation

Answer B

4 We can create the object of abstract class
A True
B False

Answer B

5 All virtual functions in an abstract base class must be declared as pure virtual functions.
A TRUE
B FALSE

Answer B
 

6 A class is made abstract by declaring that class virtual.
A TRUE
B FALSE

Answer B

7 Polymorphic programming can eliminate the need for switch logic.
A TRUE
B FALSE

Answer A

8 Suppose a and b are integer variables and we form the sum a + b. Now suppose c and
D are floating-point variables and we form the sum c + d. The two +operators here are
clearly being used for different purposes. This is an example of ____________
A Operator Overloading
B Inheritance
C Function Overloading
D Constructor

Answer A

9 The operators that cannot be overloaded is
A *
B -
C ::
D ()

Answer C

10 The operators that cannot be overloaded is
A *
B ?:
C >>
D <<

Answer B

11 Which of the following operator(s) can not be overloaded
A .*
B ::
C ?:
D All of the above

Answer D

12 Which of the following is true about this pointer?
A It is passed as a hidden argument to all function calls
B It is passed as a hidden argument to all non-static function calls
C It is passed as a hidden argument to all static functions
D None of the above

Answer B

13 Predict the output of following C++ program.
#include<iostream>
using namespace std;
class Test
{
private:
 int x;
public:
 Test(int x = 0) { this->x = x; }
 void change(Test *t) { this = t; }
 void print() { cout <<"x = "<<x <<endl; }
};
int main()
{
 Test obj(5);
 Test *ptr = new Test (10);
 obj.change(ptr);
 obj.print();
 return 0;
}
A x = 5
B x = 10
C Compiler Error
D Runtime Error

Answer C

14 Which of the followings is/are automatically added to every class, if we do not write our
own.
A Copy Constructor
B Assignment Operator
C A constructor without any parameter
D All of the above

Answer D

15 What is the output of following program?
#include<iostream>
using namespace std;
class Point {
 Point() { cout <<"Constructor called"; }
};
int main()
{
 Point t1;
 return 0;
}
A Compiler Error
B Runtime Error
C Constructor called
D Segmentation Fault

Answer A

16 What will be the output of following program?
#include <iostream>
using namespace std;
class Test
{
public:
 Test() { cout <<"Hello from Test() "; }
} a;
int main()
{
 cout <<"Main Started ";
 return 0;
}
A Main Started
B Main Started Hello from Test()
C Hello from Test() Main Started
D Compiler Error: Global objects are not allowed

Answer C

17 Which of the following operators are overloaded by default by the compiler?
1) Comparison Operator ( == )
2) Assignment Operator ( = )
A Both 1 and 2
B Only 1
C Only 2
D None of the two

Answer C

18 A normal C++ operator that acts in a special way on newly defined data types is called
_______
A Encapsulated
B Overloaded
C Classified
D Inherited
 

Answer B

19 The correct function name for overloading the addition + operator is __
A Operator _+
B Operator :+
C Operator (+)
D Operator +

Answer D

20 Which of the following operators cannot be overloaded?
A → operator
B . operator
C [ ] operator
D &operator

Answer B

21 Which of the following operators cannot be overloaded?
A +
B -
C [ ]
D ::

Answer D

22 Pick the incorrect statement from the following
A The overloaded operators follow the syntax rules of original operator.
B Only existing operators can be overloaded
C Overloaded operator must have at least one operand of its class type
D Overloaded operators can change the meaning of the original operator

Answer D

23 For operators to be overloaded as non static member functions:
A Both binary and unary operators take one argument.
B Binary operators can have one argument and unary operators can not have any
C Neither binary nor unary operators can have arguments
D Binary operators can have two arguments and unary operators can have one

Answer B

24 Which of the following is an operator function?
A Member overloading
B Function overloading
C Operator overloading
D None of these

Answer C

25 Operator overloading means _______
A Giving new meaning to existing operator without changing its original
Meaning
B Making C++ operators to work with objects
C Making new types of operator
D Both a and b

Answer D

26 For overloading =+ implicitly _______
A + and = operators need to be overloaded implicitly
B Only + operator need to be overloaded implicitly
C Only = operator need to be overloaded implicitly
D The += operator cannot be overloaded implicitly

Answer D

27 Overloading a postfix increment operator by means of a member function takes-------
A No argument
B One argument
C Two arguments
D Three Arguments

Answer A

28 If you overload only prefix operator ++ then the postfix ++ operator is ______
A Does not work
B Works arbitrarily
C Works naturally
D Works as if prefix ++ operator

Answer D

29 When compiler decides binding of an overloaded member then it is called________
A Static binding
B Dynamic binding
C Local binding
D None of these

Answer A

30 One can redefine the working of _______ to work with objects.
A Preprocessor directives
B White space characters
C Standard operators
D None of these

Answer C





Publish Your Great Work

Touch below

Your AD here