0% found this document useful (0 votes)
5 views

oops mcq

Uploaded by

hityachaudhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

oops mcq

Uploaded by

hityachaudhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

OOPS MCQ’S

………
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

2. Which of the following is not a type of constructor?

Copy constructor
Friend constructor
Default constructor
Parameterized constructor

3. Which of the following statements is correct?

Base class pointer cannot point to derived class.


Derived class pointer cannot point to base class.
Pointer to derived class cannot be created.
Pointer to base class cannot be created.

4. Which of the following is not the member of class?

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

9 .Which of the following cannot be friend?

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

11. Why reference is not same as a pointer?


A reference can never be null.
A reference once established cannot be changed.
Reference doesn't need an explicit dereferencing mechanism.
All of the above.

12. cout is a/an __________ .

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

15. Which of the following is an abstract data type?

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

17. Which of the following statement is correct?

A constructor is called at the time of declaration of an object.


A constructor is called at the time of use of an object.
A constructor is called at the time of declaration of a class.
A constructor is called at the time of use of a class.

18. Which of the following correctly describes overloading of functions?

Virtual polymorphism
Transient polymorphism
Ad-hoc polymorphism
Pseudo polymorphism

19. Which of the following approach is adapted by C++?

Top-down
Bottom-up
Right-left
Left-right

20. Which of the following is correct about function overloading?

The types of arguments are different.


The order of argument is different.
The number of argument is same.
Both A and B.
21. Which of the following is correct about class and structure?
class can have member functions while structure cannot.
class data members are public by default while that of structure are private.
Pointer to structure or classes cannot be declared.
class data members are private by default while that of structure are public by default.

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

24. How "Late binding" is implemented in C++?

Using C++ tables


Using Virtual tables
Using Indexed virtual tables
Using polymorphic tables

25 Which of the following operator is overloaded for object cout?

>>
<<
+
=

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?

Construct a new class


Construct a new object
Construct a new function
Initialize objects

29. Which of the following problem causes an exception?

Missing semicolon in statement in main().


A problem in calling function.
A syntax error.
A run-time error.

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

32. Which of the following concepts is used to implement late binding?

Virtual function
Operator function
Const function
Static function

33. Which of the following statement is correct?

C++ allows static type checking.


C++ allows dynamic type checking.
C++ allows static member function be of type const.
Both A and B.
34. Which of the following factors supports the statement that reusability is a desirable
feature of a language?

It decreases the testing time.


It lowers the maintenance cost.
It reduces the compilation time.
Both A and B.

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

36. Which of the following is a mechanism of static polymorphism?


Operator overloading
Function overloading
Templates
All of the above

37. Which of the following is correct about the statements given below?

1. All operators can be overloaded in C++.

2. We can change the basic meaning of an operator in C++.

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?

Compiler reports an error on compilation.


Only base class function will get called irrespective of object.
Only derived class function will get called irrespective of object.
Base class object will call base class function and derived class object will call derived
class function.

39. Which of the following are available only in the class hierarchy chain?

Public data members


Private data members
Protected data members
Member functions
40. Which of the following is not a type of inheritance?

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?

From inside the destructor.


From inside the constructor.
From inside the main().
Both A and B.

43. Which of the following statements regarding inline functions is correct?

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?

virtual void Display(void){0};


virtual void Display = 0;
virtual void Display(void) = 0;
void Display(void) = 0;

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

47. What will happen if a class is not having any name?

It cannot have a destructor.


It cannot have a constructor.
It is not allowed.
Both A and B.

48. Which inheritance type is used in the class given below?


class A : public X, public Y
{}

Multilevel inheritance
Multiple inheritance
Hybrid inheritance
Hierarchical Inheritance

49. Which one of the following is correct about the statements given below?

1. All function calls are resolved at compile-time in Procedure Oriented Programming.

2. All function calls are resolved at compile-time in OOPS.

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++?

Classes cannot have data as protected members.


Structures can have functions as members.
Class members are public by default.
Structure members are private by default.

53. Which of the following is used to make an abstract class?

Declaring it abstract using static keyword.


Declaring it abstract using virtual keyword.
Making at least one member function as virtual function.
Making at least one member function as pure virtual function.

54. Which of the following access specifier is used as a default in a class definition?

protected
public
private
friend

55. What is correct about the static data member of a class?

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.

56. Which of the following provides a reuse mechanism?


Abstraction
Inheritance
Dynamic binding
Encapsulation

57. which of the following statement is correct?

Class is an instance of object.


Object is an instance of a class.
Class is an instance of data type.
Object is an instance of data type.
1. Who invented OOP?
a) Andrea Ferro
b) Adele Goldberg
c) Alan Kay
d) Dennis Ritchie

2. Which is not a feature of OOP in general definitions?


a) Efficient Code
b) Code reusability
c) Modularity
d) Duplicate/Redundant data

3. Which was the first purely object oriented programming language developed?
a) Kotlin
b) SmallTalk
c) Java
d) C++

4. When OOP concept did first came into picture?


a) 1980’s
b) 1995
c) 1970’s
d) 1993

5. Which feature of OOP indicates code reusability?


a) Abstraction
b) Polymorphism
c) Encapsulation
d) Inheritance

6. Which header file is required in C++ to use OOP?


a) OOP can be used without using any header file
b) stdlib.h
c) iostream.h
d) stdio.h

7. Why Java is Partially OOP language?


a) It allows code to be written outside classes
b) It supports usual declaration of primitive data types
c) It does not support pointers
d) It doesn’t support all types of inheritance

8. Which among the following doesn’t come under OOP concept?


a) Data hiding
b) Message passing
c) Platform independent d) Data binding
9. Which is the correct syntax of inheritance?
a) class base_classname :access derived_classname{ /*define class body*/ };
b) class derived_classname : access base_classname{ /*define class body*/ };
c) class derived_classname : base_classname{ /*define class body*/ };
d) class base_classname : derived_classname{ /*define class body*/ };

10. Which feature of OOP is indicated by the following code?

class student{ int marks; };


class topper:public student{ int age; topper(int age){ this.age=age; }
};
a) Encapsulation and Inheritance
b) Inheritance and polymorphism
c) Polymorphism
d) Inheritance

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

15. What is encapsulation in OOP?


a) It is a way of combining various data members and member functions that operate
on those data members into a single unit
b) It is a way of combining various data members and member functions into a single
unit which can operate on any data
c) It is a way of combining various data members into a single unit
d) It is a way of combining various member functions into a single unit

16. Which of the following is not true about polymorphism?


a) Helps in redefining the same functionality
b) Increases overhead of function definition always
c) It is feature of OOP
d) Ease in readability of program

17. Which constructor will be called from the object created in the below C++ code?

class A
{
int i;
A()
{
i=0; cout&lt;&lt;i;
}
A(int x=0)
{
i=x; cout&lt;&lt;I;
}
};
A obj1;
a) Parameterized constructor
b) Default constructor
c) Run time error
d) Compile time error

18. What is an abstraction in object-oriented programming?


a) Hiding the implementation and showing only the features
b) Hiding the important data
c) Hiding the implementation
d) Showing the important data

19. Which among the following can show polymorphism?


a) Overloading &&
b) Overloading <<
c) Overloading ||
d) Overloading +=

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

22. The copy constructors can be used to ________


a) Copy an object so that it can be passed to another primitive type variable
b) Copy an object for type casting
c) Copy an object so that it can be passed to a function
d) Copy an object so that it can be passed to a class

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)

24. Which among the following represents correct constructor?


a) –classname()
b) classname()
c) ()classname
d) ~classname()

25. What happens when an object is passed by reference?


a) Destructor is called at end of function
b) Destructor is called when called explicitly
c) Destructor is not called
d) Destructor is called when function is out of scope

26. Which access specifier is usually used for data members of a class?
a) Protected
b) Private
c) Public
d) Default

27. How to access data members of a class?


a) Dot, arrow or direct call
b) Dot operator
c) Arrow operator
d) Dot or arrow as required

28. Which feature of OOP reduces the use of nested classes?


a) Inheritance
b) Binding
c) Abstraction
d) Encapsulation

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

31. Which of the following is not a property of an object?


a) Properties
b) Names
c) Identity
d) Attributes

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

33. Which among the following best describes the Inheritance?


a) Using the data and functions into derived segment
b) Using already defined functions in a programming language
c) Using the code already written once
d) Copying the code already written

34. Single level inheritance supports _____________ inheritance.


a) Language independency
b) Multiple inheritance
c) Compile time
d) Runtime

35. How to overcome diamond problem?


a) Using seperate derived class
b) Using virtual keyword with same name function
c) Can’t be done
d) Using alias name

36. Which keyword is used to declare virtual functions?


a) virt
b) virtually
c) virtual
d) anonymous

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

39. Where is the memory allocated for the objects?


a) Cache
b) ROM
c) HDD
d) RAM

40. Which of the following best describes member function overriding?


a) Member functions having the same name in derived class only
b) Member functions having the same name and different signature inside main
function
c) Member functions having the same name in base and derived classes
d) Member functions having the same name in base class only

41. Encapsulation and abstraction differ as ____________


a) Hiding and hiding respectively
b) Binding and Hiding respectively
c) Hiding and Binding respectively
d) Can be used any way

42. Which feature of OOP is exhibited by the function overriding?


a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance

43. How to access the private member function of a class?


a) Using class address
b) Using object of class
c) Using object pointer
d) Using address of member function

44. Which keyword should be used to declare static variables?


a) const
b) common
c) static
d) stat
45. Which is correct syntax for declaring pointer to object?
a) *className objectName;
b) className* objectName;
c) className objectName();
d) className objectName;

46. Which class/set of classes can illustrate polymorphism in the following C++ code?

abstract class student


{
public : int marks;
calc_grade();
}
class topper:public student
{
public : calc_grade()
{
return 10;
}
};
class average:public student
{
public : calc_grade()
{
return 20;
}
};
class failed{ int marks; };
a) Only class student and topper together can show polymorphism
b) Only class student can show polymorphism
c) Class failed should also inherit class student for this code to work for polymorphism
d) All class student, topper and average together can show polymorphism

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()

51. Instance of which type of class can’t be created?


a) Parent class
b) Abstract class
c) Anonymous class
d) Nested class

52. ___________ underlines the feature of Polymorphism in a class.


a) Virtual Function
b) Inline function
c) Enclosing class
d) Nested class

53. Which feature in OOP is used to allocate additional functions to a predefined


operator in any language?
a) Function Overloading
b) Function Overriding
c) Operator Overloading
d) Operator Overriding

54. Which feature can be implemented using encapsulation?


a) Polymorphism
b) Overloading
c) Inheritance
d) Abstraction
1. What is the implicit return type of constructor?
No return type
A class object in which it is defined.
void
None
Check Answer
Explanation - B) Implicit return type of constructor is the class object in which it is
defined.

2. When is the object created with a new keyword?


At run time
At compile time
Depends on the code
None
Check Answer
Explanation - A) The object created with a new keyword during run-time.

3. Identify the incorrect constructor type.


Friend constructor
Default constructor
Parameterized constructor
Copy constructor
Check Answer
Explanation - A) Friend constructor is not a type of constructor.

4. Identify the scope resolution operator.


:
::
?:
None
Check Answer
Answer - B) :: is the scope resolution operator.

5. choose the option below which is not a member of the class.


Friend function
Static function
Virtual function
Const function
Check Answer
Answer - A) Friend function is not a member of the class.

6. Total types of constructors in C++ are?


1
2
3
4
Check Answer
Answer - C) There are three types of constructors in C++ - .default constructor,
parameterized constructor and copy constructor.
7. What is the number of parameters that a default constructor requires?
0
1
2
3
Check Answer

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.

11. Which of the following is not a type of inheritance?


Multiple
Multilevel
Distributed
Hierarchical
Check Answer
Answer - C) Distributed is not a type of inheritance.

12. What is an object in c++?


It is a function of class
It is an instance of the class
It is the data type of class
It is part of the syntax of class.
Check Answer
Answer - B) An object is an instance of the class.
13. Why is reusability a desirable feature?
Reduces compilation time
Decreases testing time
Lowers maintenance cost
None
Check Answer
Answer - B) Reusability is a desirable feature as it decreases the testing time.

14. Identify the operators which cannot be overloaded.


?:
.(dot operator)
>>
Both A and B
Check Answer
Answer - C) >> cannot be overloaded.

15. Another name of overloading is?


Pseudo polymorphism
Transient polymorphism
Virtual polymorphism
Ad-hoc polymorphism
Check Answer
Answer - D) Overloading is also known as Ad-hoc polymorphism.

16. By default, fields in a structure of a C program is?


public
Private
protected
None
Check Answer
Answer - A) Fields in the structure are public by default

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.

20. Choose the option below which can show polymorphism.


Overloading ||
Overloading <<
Overloading &&
Overloading +=
Check Answer
Answer - B) Overloading << can show polymorphism.

21. Select the following which shows the correct constructor.


()class_name
-class_name
class_name()
~class_name()
Check Answer
Answer - C) class_name() is the correct constructor.

22. To access data members of a class, which of the following is used?


Dot operator
Arrow operator
Dot or arrow operator, as required
Dot, arrow, or direct call
Check Answer
Answer - C) To access data members of a class, Dot or arrow operator, as required.

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.

26. What type of inheritance does single-level inheritance support?


Compile-time
Runtime inheritance
Multiple inheritances
Language independent
Check Answer
Answer - B) Single-level inheritance supports Runtime inheritance.

27. In which of the following is memory allocated for the objects?


RAM
ROM
Cache
HDD
Check Answer
Answer - A) Memory is allocated for the objects in RAM

28. How do encapsulation and abstraction differ?


Hiding and binding
Binding and hiding
Hiding and hiding
None
Check Answer
Answer - B) Encapsulation and abstraction differ on the basis of binding and hiding.

29. Choose the option below which is shown by function overriding


Abstraction
Encapsulation
Polymorphism
Inheritance
Check Answer
Answer - C). Function overriding shows polymorphism.

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.

32. Why is a virtual function mainly used to achieve?


Function code polymorphism
Interpreter polymorphism
Compile-time polymorphism
Runtime polymorphism
Check Answer
Answer - D) Virtual function mainly used to achieve Runtime polymorphism.

33. Virtual functions should be defined in?


Derived class
Base class
Both base and derived class
None
Check Answer
Answer - B) Virtual functions should be defined in the base class.

34. Virtual function should be ________.


public
Private
protected
default
Check Answer
Answer - A) Virtual functions should be public.

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.

36. Dynamic memory allocation can be done using?


calloc()
malloc()
Both (a) and (b)
create()
Check Answer
Answer - C) Dynamic memory allocation can be done using both calloc() and malloc().

37. Total types of polymorphism in C++ are?


1
2
3 Answer - B) There is a total of 2 types of polymorphism in C++ - runtime
polymorphism and compile-time polymorphism.
38. Another name of the generic class is?
Template class
Final class
Abstract class
Efficient code
Check Answer
Answer - A) Generic class is also known as a template class.

39. Choose the option below which overloads using the friend function.
()
->
*
=
Check Answer
Answer - C) * can be overloaded using the friend function.

40. Choose whether True or False: Object cannot be passed as a function.


True
False
Depends on implementation
None
Check Answer
Answer - A) True. The object cannot be passed as a 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.

42. Identify the abstract data type among the following.


double
int
class
string
Check Answer
Answer - C) Class is an abstract data type.

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.

45. Total instances of an abstract class that can be created?


0
1
4
8
Check Answer
Answer - A) Instances of abstract class cannot be made.

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.

49. What is cout?


Operator
Object
Function
Macro
Check Answer
Answer - B) cout is an object.

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.

52. Which of the following is not an oops concept?


Inheritance
Compilation
Polymorphism
Encapsulation
Check Answer
1 What happens when we try to compile the class definition in following code snippet?

class Birds {};


class Peacock : protected Birds {};

It will not compile because class body of Birds is not defined.


It will not compile because class body of Peacock is not defined.
It will not compile because a class cannot be protectedly inherited from other class.
It will compile succesfully.

2.Which of the following statements is incorrect?

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().

3.Which of the following statement is correct regarding destructor of base class?

Destructor of base class should always be static.


Destructor of base class should always be virtual.
Destructor of base class should not be virtual.
Destructor of base class should always be private.

4. Which of the following two entities (reading from Left to Right) can be connected by the dot
operator?

A class member and a class object.


A class object and a class.
A class and a member of that class.
A class object and a member of that class.

5. How can we make a class abstract?

By making all member functions constant.


By making at least one member function as pure virtual function.
By declaring it abstract using the static keyword.
By declaring it abstract using the virtual keyword.
6. Which of the following statements is correct when a class is inherited publicly?
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 protected members of derived class.
Public members of the base class become public members of derived class.

7. Which of the following statements is correct about the constructors and destructors?

Destructors can take arguments but constructors cannot.


Constructors can take arguments but destructors cannot.
Destructors can be overloaded but constructors cannot be overloaded.
Constructors and destructors can both return a value.

8. Which of the following access specifies is used in a class definition by default?

Protected
Public
Private
Friend

9. Which of the following statement is correct with respect to the use of friend keyword
inside a class?

A private data member can be declared as a friend.


A class may be declared as a friend.
An object may be declared as a friend.
We can use friend keyword as a class name.

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

13 Which of the following also known as an instance of a class?

Friend Functions
Object
Member Functions
Member Variables

14. Constructor is executed when _____.

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?

It is used to provide multiple inheritance.


It is used to avoid multiple copies of base class in derived class.
It is used to allow multiple copies of base class in a derived class.
It allows private members of the base class to be inherited in the derived class.

16. How many objects can be created from an abstract class?


Zero
One
Two
As many as we want
17. What does the class definitions in following code represent?

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.

19. Which of the following statements is correct?

Data items in a class must be private.


Both data and functions can be either private or public.
Member functions of a class must be private.
Constructor of a class cannot be private.

20. What does a class hierarchy depict?

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

21. Which of the following can be overloaded?


Object
1) Functions
2) Operators 3) Both B and C
22. Which of the following means "The use of an object of one class in definition of another
class"?

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?

1. It can access only other static members of its class.

2. It can be called using the class name, instead of objects.

1) Only 1 is correct. 2) Only 2 is correct.


3) Both 1 and 2 are correct. 4) Both 1 and 2 are incorrect.

You might also like