You are on page 1of 7

OOPS

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


i) Pass by value
ii) Pass by reference
iii) Pass by pointer
iv) All the above
2) Constant function in C++ can be declared as
i) void display()
ii) void display() const
iii) const void display()
iv) void const display()
3) Which of the following functions are provided by compiler by default if we don’t write in a C++
class?
i) Copy constructor
ii) Assignment
iii) Constructor
iv) All the above
4) Which function can be called without using an object of a class in C++
i) Static function
ii) Inline function
iii) Friend function
iv) constant function
5) Which of the following function declaration using default arguments is incorrect?
i) int foo(int x, int y =5, int z=10)
ii) int foo(int x=5, int y =10, int z)
iii) int foo(int x=5, int y, int z=10)
iv) all are correct
6) Which function cannot be overloaded in C++ program?
i) Virtual function
ii) member function
iii) Static function
iv) All can be overloaded
7) Overloaded functions in C++ oops are
i) Functions preceding with virtual keywords.
ii) Functions inherited from base class to derived class.
iii) Two or more functions having same name but different number of parameters or type.
iv) None of above
8) Correct way to declare pure virtual function in a C++ class is
i) virtual void foo() =0 ;
ii) void virtual foo()= { 0 }
iii) virtual void foo() {} = 0;
iv) None
OOPS

9) Compile time polymorphism in C++ language are


i) Operator overloading
ii) Function overloading
iii) Function overriding
iv) B Only
v) A & B
10) C++ abstract class can contain
i) Pure virtual function
ii) Non-virtual function
iii) Only pure virtual function
iv) Both pure virtual and non-virtual function
11) False statements about function overloading is
i) Defining multiple functions with same name in a class is called function overloading
ii) Overloaded function must differ in their order and types of arguments.
iii) Overloaded functions should be preceded with virtual keyword
iv) No statement is false
12) Following keyword is used before a function in a base class to be overridden in derived class in C++
i) override
ii) virtual
iii) void
iv) none
13) Which of the following cannot be overloaded in C++?
i) Increment operator
ii) Constructor
iii) Destructor
iv) New and delete operator
14) Which is the correct declaration of pure virtual function in C++
i) virtual void func = 0;
ii) virtual void func() = 0;
iii) virtual void func(){0};
iv) void func() = 0;
15) In a class, pure virtual functions in C++ is used
i) To create an interface
ii) To make a class abstract
iii) To force derived class to implement the pure virtual function
iv) All the above
16) Which public member of a base class cannot be inherited?
i) Constructor
ii) Destructor
iii) Both A & B
iv) Only B
OOPS

17) How many VPTR is created internally for a base class and a derived class
i) 0
ii) 1
iii) 2
iv) 3
18) Number of virtual table created for a base and a derived class is
i) 0
ii) 1
iii) 2
iv) 3
19) Interface class in C++ is created by
i) Using interface keyword before class
ii) Using pure virtual function
iii) Using pure virtual function and virtual function both
iv) Using class keyword
20) Which statements are true about an abstract class
i) Abstract class has at least one pure virtual function.
ii) Pointer for an abstract class can be created
iii) Object of an abstract class cannot be created.
iv) All are correct.
21) Run time polymorphism in C++ Program is
i) New and delete operator overloading
ii) ++ and – – operator overloading
iii) :: operator overloading
iv) None
22) Run time binding is related to
i) Function overriding
ii) Operator overloading
iii) A & B
iv) None
23) Which function cannot be overloaded in C++
i) Constructor
ii) Class destructor
iii) Both a & b
iv) None
24) Operators can be overloaded in C++ is/are
i) New
ii) Delete
iii) ++
iv) All can be overloaded
OOPS

25) Inheritance base class and derived class relationship comes under
i) Inheritance
ii) Polymorphism
iii) encapsulation
iv) None
26) C++ Inheritance relationship is
i) Association
ii) Is-A
iii) Has-A
iv) None
27) Types of inheritance in C++ are
i) Multilevel
ii) Multiple
iii) Hierarchical
iv) All the above
28) Inheritance allow in C++ Program?
i) Class Re-usability
ii) Creating a hierarchy of classes
iii) Extendibility
iv) All
29) Functions that can be inherited from base class in C++ program
i) Constructor
ii) Destructor
iii) Static function
iv) None
30) Which members of base class are inaccessible to derived class
i) Private
ii) Protected
iii) Public
iv) None
31) Accessing functions from multiple classes to a derived class is known as
i) multiple inheritance
ii) single inheritance
iii) Hybrid inheritance
iv) multilevel inheritance
32) In inheritance, order of execution of base class and derived class destructors are
i) Base to derived
ii) Derived to base
iii) Random order
iv) None
OOPS

33) In C++, Class object created statically(e.g. Car obj; and dynamically (Car *obj = new Car() ; ) are
stored in memory
i) Stack, heap
ii) Heap, heap
iii) Heap, stack
iv) Stack, stack
34) True statement about Class and structure in C++ is
i) Default access specifier is private in class and public in structure
ii) Way of creating objects of class and structure are different
iii) Way of inheriting class and structure are different
iv) None
35) In C++ programming, cout is a/an
i) Function
ii) Operator
iii) Object
iv) Macro
36) Which is Abstract Data Type in C++
i) Class
ii) Int
iii) Float
iv) array
37) Class allows only one object of it to be created though out the program life cycle
i) Singleton class
ii) Abstract class
iii) Friend class
iv) All classes
38) Statically allocated object for class A in C++ is
i) A *obj = new A();
ii) A obj;
iii) A obj = new A();
iv) None
39) When you create an object of a class A like A obj ; then which one will be called automatically
i) Constructor
ii) Destructor
iii) Copy constructor
iv) Assignment operator
40) When you create an object of a derived class in C++
i) Derived class constructor is called first then the base class constructor
ii) Base class constructor is called first then derived class constructor
iii) base class constructor will not be called
iv) none of the above
OOPS

41) The class in C++ which act only as a base class and object of it cannot be created is
i) parent class
ii) super class
iii) abstract class
iv) none of the above
42) Which operator is used to allocate an object dynamically of a class in C++?
i) Scope resolution operator
ii) Conditional operator
iii) New operator
iv) Membership access

43) Which concept is not available in C++?


i) Virtual constructor
ii) Virtual destructor
iii) Virtual function
iv) Virtual Table

44) What is VPTR ( V Table pointer)?


i) Holds the address of the V table
ii) Holds the address of the virtual functions
iii) Holds the address of pure virtual functions
iv) None

45) Who initializes the VPTR?


i) Constructor initialize the VPTR
ii) By default, initiation is done
iii) Class itself
iv) None
OOPS

You might also like