oops mcq
oops mcq
………
1. Which of the following type of class allows only one object of it to be created?
Virtual class
Abstract class
Singleton class
Friend class
Copy constructor
Friend constructor
Default constructor
Parameterized constructor
Static function
Friend function
Const function
Virtual function
5. Which of the following concepts means determining at runtime what method to invoke?
Data hiding
Dynamic Typing
Dynamic binding
Dynamic loading
6. Which of the following term is used for a function defined inside a class?
Member Variable
Member function
Class function
Classic function
7. Which of the following concept of oops allows compiler to insert arguments in a function
call if it is not specified?
Call by value
Call by reference
Default arguments
Call by pointer
8. How many instances of an abstract class can be created?
5
13
0
Function
Class
Object
Operator function
10. Which of the following concepts of OOPS means exposing only necessary information
to client?
Encapsulation
Abstraction
Data hiding
Data binding
operator
function
object
macro
13. Which of the following concepts provides facility of using object of one class inside
another class?
Encapsulation
Abstraction
Composition
Inheritance
14. How many types of polymorphisms are supported by C++?
1
2
3
4
int
double
string
Class
Which of the following concepts means adding new components to a program as it runs?
Data hiding
Dynamic typing
Dynamic binding
Dynamic loading
Virtual polymorphism
Transient polymorphism
Ad-hoc polymorphism
Pseudo polymorphism
Top-down
Bottom-up
Right-left
Left-right
22. Which of the following concepts means wrapping up of data and functions together?
Abstraction
Encapsulation
Inheritance
Polymorphism
23. Which of the following concepts means waiting until runtime to determine which
function to call?
Data hiding
Dynamic casting
Dynamic binding
Dynamic loading
>>
<<
+
=
26. Which of the following is the correct class of the object cout?
iostream
istream
ostream
ifstream
27. Which of the following cannot be used with the keyword virtual?
class
member functions
constructor 4 ) destructor
28. Which of the following functions are performed by a constructor?
30. Which one of the following options is correct about the statement given below? The
compiler checks the type of reference in the object and not the type of object.
Inheritance
Polymorphism
Abstraction
Encapsulation
31. Which of the following is the correct way of declaring a function as constant?
const int ShowData(void) { /* statements */ }
int const ShowData(void) { /* statements */ }
int ShowData(void) const { /* statements */ }
Both A and B
Virtual function
Operator function
Const function
Static function
35. Which of the following ways are legal to access a class data member using this
pointer?
this->x
this.x
*this.x
*this-x
37. Which of the following is correct about the statements given below?
Only I is true.
Both I and II are false.
Only II is true.
Both I and II are true.
38 What happens if the base and derived class contains definition of a function with
same prototype?
39. Which of the following are available only in the class hierarchy chain?
Multiple
Multilevel
Distributive
Hierarchical
41.
Which of the following operators cannot be overloaded?
[]
->
?:
*
42. In which of the following a virtual call is resolved at the time of compilation?
It speeds up execution.
It slows down execution.
It increases the code size.
Both A and C.
44. Which one of the following is the correct way to declare a pure virtual function?
45. Which of the following header file includes definition of cin and cout?
istream.h
ostream.h
iomanip.h
iostream.h
46. Which of the following keyword is used to overload an operator?
overload
operator
friend
override
Multilevel inheritance
Multiple inheritance
Hybrid inheritance
Hierarchical Inheritance
49. Which one of the following is correct about the statements given below?
Only II is correct.
Both I and II are correct.
Only I is correct.
Both I and II are incorrect.
50. Which of the following is an invalid visibility label while inheriting a class?
public
private
protected
friend
51.
Which one of the following options is correct?
Friend function can access public data members of the class.
Friend function can access protected data members of the class.
Friend function can access private data members of the class.
All of the above.
52. Which of the following statements is correct in C++?
54. Which of the following access specifier is used as a default in a class definition?
protected
public
private
friend
A static member function can access only static data members of a class.
A static data member is shared among all the object of the class.
A static data member can be accessed directly from main().
Both A and B.
3. Which was the first purely object oriented programming language developed?
a) Kotlin
b) SmallTalk
c) Java
d) C++
11. The feature by which one object can interact with another object is _____________
a) Message reading
b) Message Passing
c) Data transfer
d) Data Binding
12. Which among the following, for a pure OOP language, is true?
a) The language should follow at least 1 feature of OOP
b) The language must follow only 3 features of OOP
c) The language must follow all the rules of OOP
d) The language should follow 3 or more features of OOP
13. How many types of access specifiers are provided in OOP (C++)?
a) 4
b) 3
c) 2
d) 1
14. In multilevel inheritance, which is the most significant feature of OOP used?
a) Code efficiency
b) Code readability
c) Flexibility
d) Code reusability
17. Which constructor will be called from the object created in the below C++ code?
class A
{
int i;
A()
{
i=0; cout<<i;
}
A(int x=0)
{
i=x; cout<<I;
}
};
A obj1;
a) Parameterized constructor
b) Default constructor
c) Run time error
d) Compile time error
20. In which access should a constructor be defined, so that object of the class can be
created in any function?
a) Any access specifier will work
b) Private
c) Public
d) Protected
21. Which among the following is correct for the class defined below?
class student
{
int marks;
public: student(){}
student(int x)
{
marks=x;
}
};
main()
{
student s1(100);
student s2();
student s3=100;
return 0;
}
a) Program will give compile time error
b) Object s3, syntax error
c) Only object s1 and s2 will be created
d) Program runs and all objects are created
23. Which constructor will be called from the object obj2 in the following C++
program?
class A
{
int i;
A()
{
i=0;
}
A(int x)
{
i=x+1;
}
A(int y, int x)
{
i=x+y;
}
};
A obj1(10);
A obj2(10,20);
A obj3;
a) A(int y, int x)
b) A(int y; int x)
c) A(int y)
d) A(int x)
26. Which access specifier is usually used for data members of a class?
a) Protected
b) Private
c) Public
d) Default
29. Which keyword among the following can be used to declare an array of objects in
java?
a) allocate
b) arr
c) new
d) create
30. Which operator can be used to free the memory allocated for an object in C++?
a) Unallocate
b) Free()
c) Collect
d) delete
32. Which type of members can’t be accessed in derived classes of a base class?
a) All can be accessed
b) Protected
c) Private
d) Public
37. What happens if non static members are used in static member function?
a) Executes fine
b) Compile time error
c) Executes if that member function is not used d) Runtime error
38. What is friend member functions in C++?
a) Non-member functions which have access to all the members (including private) of
a class
b) Member function which doesn’t have access to private members
c) Member function which can modify any data of a class
d) Member function which can access all the members of a class
46. Which class/set of classes can illustrate polymorphism in the following C++ code?
47. If data members are private, what can we do to access them from the class object?
a) Private data members can never be accessed from outside the class
b) Create public member functions to access those data members
c) Create private member functions to access those data members
d) Create protected member functions to access those data members
48. Which among the following is not a necessary condition for constructors?
a) Its name must be same as that of class
b) It must not have any return type
c) It must contain a definition body
d) It can contains arguments
49. Object being passed to a copy constructor ___________
a) Must not be mentioned in parameter list
b) Must be passed with integer type
c) Must be passed by value
d) Must be passed by reference
50. If in multiple inheritance, class C inherits class B, and Class B inherits class A. In
which sequence are their destructors called if an object of class C was declared?
a) ~A() then ~B() then ~C()
b) ~C() then ~A() then ~B()
c) ~C() then ~B() then ~A()
d) ~B() then ~C() then ~A()
8. Data members and member functions of a class are private. default. True or False?
True
False
Depends on code
None
Check Answer
Answer - A) True. Data members and member functions of a class are always private by
default.
9. Under which pillar of OOPS do base class and derived class relationships come?
Polymorphism
Inheritance
Encapsulation
Abstraction
Check Answer
Answer - B) Base class and derived class relationship come under inheritance.
10. Which of the following functions can be inherited from the base class?
Constructor
Destructor
Static
None
Check Answer
Answer - D) None of the functions can be inherited from the base class.
17. On what basis is it determined, when a variable comes into existence in memory?
Data type
Storage class
Scope
All of the above
Check Answer
Answer - B) A variable that comes into existence in memory is determined by storage
class.
18. Identify the feature using which, one object can interact with another object.
Message passing
Message reading
Data binding
Data transfer
Check Answer
Answer - A) Message passing is the feature using which, one object can interact with
another object
19. Total access specifiers in OOPS for C++ are?
1
2
3
4
Check Answer
Answer - C) There is a total of 3 access specifiers - private, public, protected.
23. Identify the feature, which is used to reduce the use of nested classes.
Binding
Inheritance
Encapsulation
Abstraction
Check Answer
Answer - B) Inheritance is the feature. which is used to reduce the use of nested classes.
24. Choose the option below which is used to free the memory allocated for an object
in C++.
Free()
unallocate()
delete
collect
Check Answer
Answer - C) delete is used to free the memory allocated for an object in C++.
25. Identify the option below which is not a property of the object.
Names
Attributes
Identity
Properties
Check Answer
Answer - A) Names are not a property of the object.
30. Choose the option below for which instance of the class cannot be created.
Anonymous class
Parent class
Nested class
Abstract class
Check Answer
Answer - D) For the Abstract class, an instance of a class cannot be created.
31. Identify the feature which can be implemented using encapsulation.
Abstraction
Encapsulation
Polymorphism
Inheritance
Check Answer
Answer - A) Abstraction can be implemented using encapsulation.
35. Choose whether True or False: The constructor function can be constant.
True
False
Depends on implementation
None
Check Answer
Answer - B) False. Constructor function cannot be constant.
39. Choose the option below which overloads using the friend function.
()
->
*
=
Check Answer
Answer - C) * can be overloaded using the friend function.
41. Identify the pure object-oriented programming language among the following.
C++
SmallTalk
Java
Python
Check Answer
Answer - B) SmallTalk is a pure object-oriented programming language.
43. What are the total catch blocks that can be used using a single Try block?
1
2
According to needs
Maximum 256
Check Answer
Answer - C) We can use as many catch blocks as required using a single Try block.
44. Choose the incorrect option below which is not a type of constructor.
Copy constructor
Friend constructor
Parameterized constructor
Default constructor
Check Answer
Answer - B). Friend constructor is not a type of constructor.
46. Identify the option below which cannot be used with the term “virtual”.
constructor
destructor
class
Member function
Check Answer
Answer - A) Constructor cannot be used with the term “virtual”.
47. Which type of inheritance is implemented in the following code below?
Single inheritance
Multilevel inheritance
Hybrid inheritance
Multiple inheritances
Check Answer
Answer - D) Multiple inheritances are implemented in the above code.
48. Choose the option below which is used to implement late binding.
Friend function
Static function
Virtual function
Const function
Check Answer
Answer - C) Virtual function is used to implement late binding.
50. Choose the option below which describes the overloading of functions.
Ad-hoc polymorphism
Virtual polymorphism
Pseudo polymorphism
Transient polymorphism
Answer - A) Ad-hoc polymorphism correctly describes the overloading of functions
51. who developed object-oriented programming?
Dennis Ritchie
Charles Babbage
Alan Kay
Andrea Ferro
Check Answer
Answer - C) Object-oriented programming was developed by Alan Kay.
Friend keyword can be used in the class to allow access to another class.
Friend keyword can be used for a function in the public section of a class.
Friend keyword can be used for a function in the private section of a class.
Friend keyword can be used on main().
4. Which of the following two entities (reading from Left to Right) can be connected by the dot
operator?
7. Which of the following statements is correct about the constructors and destructors?
Protected
Public
Private
Friend
9. Which of the following statement is correct with respect to the use of friend keyword
inside a class?
10. Which of the following keywords is used to control access to a class member?
Default
Break
Protected
Asm
11. Which of the following can access private data members or member functions of a
class?
Any function in the program.
All global functions in the program.
Any member function of that class.
Only public member functions of that class.
12. Which of the following type of data member can be shared by all instances of its
class?
Public
Inherited
Static
Friend
Friend Functions
Object
Member Functions
Member Variables
an object is created
an object is used
a class is declared
an object goes out of scope.
15. Which of the following statements about virtual base classes is correct?
class Bike
{
Engine objEng;
};
class Engine
{
float CC;
};
kind of relationship
has a relationship
Inheritance
Both A and B
18. Which of the following statements is correct when a class is inherited privately?
Public members of the base class become protected members of derived class.
Public members of the base class become private members of derived class.
Private members of the base class become private members of derived class.
Public members of the base class become public members of derived class.
It shows the relationships between the classes in the form of an organization chart.
It describes "has a" relationships.
It describes "kind of" relationships.
It shows the same relationship as a family tree
Encapsulation
Inheritance
Composition
Abstraction
23. Which of the following is the only technical difference between structures and classes
in C++?
Member function and data are by default protected in structures but private in classes.
Member function and data are by default private in structures but public in classes.
Member function and data are by default public in structures but private in classes.
Member function and data are by default public in structures but protected in classes.
24. Which of the following statements is correct about the program given below?
class Bix
{
public:
static void MyFunction();
};
int main()
{
void(*ptr)() = &Bix::MyFunction;
return 0;
}
The program reports an error as pointer to member function cannot be defined outside the
definition of class.
The program reports an error as pointer to static member function cannot be defined.
The program reports an error as pointer to member function cannot be defined without
object.
The program reports linker error.
25. Which of the following statements are correct for a static member function?