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

CPP MCQ - 1

The document provides a list of 60 questions and answers related to object-oriented programming concepts in C++. Key concepts covered include abstraction, encapsulation, inheritance, polymorphism, classes, objects, and relationships between base and derived classes.

Uploaded by

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

CPP MCQ - 1

The document provides a list of 60 questions and answers related to object-oriented programming concepts in C++. Key concepts covered include abstraction, encapsulation, inheritance, polymorphism, classes, objects, and relationships between base and derived classes.

Uploaded by

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

CPP/OOPS IMP QUESTIONS

1) The OOPs concept in C++, exposing only necessary information to users or clients is known
as

A) Abstraction

B) Encapsulation

C) Data hiding

D) Hiding complexity

Answer: A

2) Which of the following is an abstract data type?

A) Class

B) Int

C) String

D) Double

Answer: A

3) Hiding the complexity is known as

A) Abstraction

B) Encapsulation

C) Data hiding

D) Composition

Answer: B
4) For Cat and Animal class, correct way of inheritance is

A) class Cat: public Animal

B) class Animal: public Cat

C) Both are correct way

D) None is correct way

Answer: A

5) In a class, encapsulating an object of another class is called

A) Composition

B) Inheritance

C) Encapsulation

D) None

Answer: A

6) Features not available in C++ object oriented programming is

A) Virtual destructor

B) Virtual constructor

C) Virtual function

D) All

Answer: B

7) IS A relationship in C++ is

A) Inheritance

B) Encapsulation
C) Composition

D) None

Answer: A

8) If you want to write multiple functions in a class with same name, then what C++ feature
will you use?

A) Function overriding

B) Encapsulation

C) Function overloading

D) None

Answer: C

9) Polymorphism types is/are

A) Compile time

B) Run time

C) Both

B) None

Answer: C

10) If I want to have common functions in a class and want to defer implementations of some
other functions to derived classes, then we need to use

A) An interface

B) An abstract class

C) A friend class

D) A static class
Answer: B

11) Not using virtual destructor feature in a C++ object oriented programing can cause

A) Memory leak

B) An Issue in creating object of the class

C) An issue in calling base class destructor

D) Nothing

Answer: A

12) Which C++ oops feature is related to re-usability?

A) Encapsulation

B) Inheritance

C) Abstraction

D) None

Answer: B

13) Correct way of creating an object of a class called Car is

A) Car obj;

B) Car *obj = new Car();

C) Only B

D) A & B both

Answer: D

14) In C++, Class object created statically(e.g. Car obj; and dynamically (Car *obj = new Car() ;
) are stored in memory

A) Stack, heap

B) Heap, heap

C) Heap, stack

D) Stack, stack

Answer: A

15) True statement about Class and structure in C++ is

A) Default access specifier is private in class and public in structure

B) Way of creating objects of class and structure are different

C) Way of inheriting class and structure are different

D) None

Answer: A

16) In C++ programming, cout is a/an

A) Function

B) Operator

C) Object

D) macro

Answer: C

17) Which is Abstract Data Type in C++

A) Class

B) Int
C) Float

D) array

Answer: A

18) Class allows only one object of it to be created though out the program life cycle

A) Singleton class

B) Abstract class

C) Friend class

D) All classes

Answer: A

19) Statically allocated object for class A in C++ is

A) A *obj = new A();

B) A obj;

C) A obj = new A();

D) None

Answer: B

20) When you create an object of a class A like A obj ; then which one will be called
automatically

A) Constructor

B) Destructor

C) Copy constructor

D) Assignment operator
Answer: A

21) When you create an object of a derived class in C++

A) Derived class constructor is called first then the base class constructor

B) Base class constructor is called first then derived class constructor

C) base class constructor will not be called

D) none of the above

Answer: B

22) The class in C++ which act only as a base class and object of it cannot be created is

A) parent class

B) super class

C) abstract class

D) none of the above

Answer: C

23) Data members and member functions of a class in C++ program are by default

A) protected

B) public

C) private

D) None

Answer: C

24) Which operator is used to allocate an object dynamically of a class in C++?


A) Scope resolution operator

B) Conditional operator

C) New operator

D) Membership access

Answer: C

25) Which is used to define the member function of a class externally?

A) :

B) ::

C) #

D) None

Answer: B

26) In C++, an object cannot be created for

A) An interface

B) An Abstract class

C) A singleton class

D) A & B

E) A, B & C

Answer: D

27) By default functions available in C++ language are

A) Constructor

B) Destructor
C) Copy constructor

D) Assignment operator

E) All

Answer: E

28)base class and derived class relationship comes under

A) Inheritance

B) Polymorphism

C) encapsulation

D) None

Answer : A

29) C++ Inheritance relationship is

A) Association

B) Is-A

C) Has-A

D) None

Answer:B

30) Types of inheritance in C++ are

A) Multilevel

B) Multiple

C) Hierarchical

D) All the above


Answer: D

31) Inheritance allow in C++ Program?

A) Class Re-usability

B) Creating a hierarchy of classes

C) Extendibility

D) All

Answer: D

32) Functions that can be inherited from base class in C++ program

A) Constructor

B) Destructor

C) Static function

D) None

Answer:D

33)____________ members of base class are inaccessible to derived class

A) Private

B) Protected

C) Public

D) None

Answer:A

34) Accessing functions from multiple classes to a derived class is known as


A) multiple inheritance

B) single inheritance

C) Hybrid inheritance

D) multilevel inheritance

Answer:A

35) In inheritance, order of execution of base class and derived class destructors are

A) Base to derived

B) Derived to base

C) Random order

D) none

Answer: B

36) Compile time polymorphism in C++ language are

A) Operator overloading

B) Function overloading

C) Function overriding

D) B Only

E) A & B

Answer: E

37) C++ abstract class can contain

A) Pure virtual function

B) Non-virtual function
C) Only pure virtual function

D) Both pure virtual and non-virtual function

Answer: D

38) False statements about function overloading is

A) Defining multiple functions with same name in a class is called function overloading

B) Overloaded function must differ in their order and types of arguments.

C) Overloaded functions should be preceded with virtual keyword

D) No statement is false

Answer: C

39) Following keyword is used before a function in a base class to be overridden in derived
class in C++

A) override

B) virtual

C) void

D) none

Answer: B

40) Which of the following cannot be overloaded in C++?

A) Increment operator

B) Constructor

C) Destructor

D) New and delete operator


Answer: C

41) Which is the correct declaration of pure virtual function in C++

A) virtual void func = 0;

B) virtual void func() = 0;

C) virtual void func(){0};

D) void func() = 0;

Answer: B

42) In a class, pure virtual functions in C++ is used

A) To create an interface

B) To make a class abstract

C) To force derived class to implement the pure virtual function

D) All the above

Answer: D

43) Which public member of a base class cannot be inherited?

A) Constructor

B) Destructor

C) Both A & B

D) Only B

Answer: C

44) How many VPTR is created internally for a base class and a derived class
A) 0

B) 1

C) 2

D) 3

Answer: B

45) Number of virtual table created for a base and a derived class is

A) 0

B) 1

C) 2

D) 3

Answer: C

46) Interface class in C++ is created by

A) Using interface keyword before class

B) Using pure virtual function

C) Using pure virtual function and virtual function both

D) Using class keyword

Answer: B

47) Which statements are true about an abstract class

A) Abstract class has at least one pure virtual function.

B) Pointer for an abstract class can be created

C) Object of an abstract class cannot be created.


D) All are correct.

Answer: D

48) Run time polymorphism in C++ Program is

A) New and delete operator overloading

B) ++ and – – operator overloading

C) :: operator overloading

D) None

Answer: D

49) Run time binding is related to

A) Function overriding

B) Operator overloading

C) A & B

D) None

Answer: A

50) Which function cannot be overloaded in C++

A) Constructor

B) Class destructor

C) Both a & b

D) None

Answer: B
51) Operators can be overloaded in C++ is/are

A) New

B) Delete

C) ++

D) All can be overloaded

Answer: D

52) In C++ code , variables can be passed to a function by

A) Pass by value

B) Pass by reference

C) Pass by pointer

D) All the above

Answer: D

53) Constant function in C++ can be declared as

A) void display()

B) void display() const

C) const void display()

D) void const display()

Answer: B

54) Which of the following functions are provided by compiler by default if we don’t write in
a C++ class?

A) Copy constructor
B) Assignment

C) Constructor

D) All the above

Answer: D

55) Which function can be called without using an object of a class in C++

A) Static function

B) Inline function

C) Friend function

D) constant function

Answer: A

56) True and false about inline function statements in C++

class A{

public:

void func1(){

void func2();

};

inline void A::func2(){

A) Func1 is inline function

B) Func2 only is inline function


C) Func1 and Func2 both are inline functions

D) None of the above is inline

Answer: C

57) Which function can be called without using an object of a class in C++

A) Virtual function

B) Inline function

C) Static function

D) constant function

Answer: C

58) Which of the following function declaration using default arguments is correct?

A) int foo(int x, int y =5, int z=10)

B) int foo(int x=5, int y =10, int z)

C) int foo(int x=5, int y, int z=10)

D) all are correct

Answer: A

59) Which function cannot be overloaded in C++ program?

A) Virtual function

B) member function

C) Static function

D) All can be overloaded

Answer: C
60) Choose the correct answer for following piece of C++ pseudo code

void func(int a, int &b)

int main(){

int a,b;

func(a,b);

A) a is pass by value and b is pass by reference

B) a is pass by reference and b is pass by value

C) a is pass by value and b is pass by address

D) a is pass by value and b is pass by pointer

Answer: A

You might also like