Q.1
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
Q.2
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= return}
  • 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
Q.3
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
Q.4
Which constructor will be called from the object obj2 in the following C++ program? class A { int i; A() { i= } A(int x) { i=x+ } 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)
Q.5
Which among the following represents correct constructor?
  • b) classname()
  • c) ()classname
  • d) ~classname()
  • a) –classname()
Q.6
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
Q.7
Which access specifier is usually used for data members of a class?
  • a) Protected
  • b) Private
  • c) Public
  • d) Default
Q.8
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
Q.9
Which feature of OOP reduces the use of nested classes?
  • a) Inheritance
  • b) Binding
  • c) Abstraction
  • d) Encapsulation
Q.10
Which keyword among the following can be used to declare an array of objects in java?
  • a) allocate
  • b) arr
  • c) new
  • d) create
Q.11
Which operator can be used to free the memory allocated for an object in C++?
  • a) Unallocate
  • b) Free()
  • c) Collect
  • d) delete
Q.12
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
Q.13
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
Q.14
Single level inheritance supports _____________ inheritance.
  • a) Language independency
  • b) Multiple inheritance
  • c) Compile time
  • d) Runtime
Q.15
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
Q.16
Which keyword is used to declare virtual functions?
  • a) virt
  • b) virtually
  • c) virtual
  • d) anonymous
Q.17
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
Q.18
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
Q.19
Where is the memory allocated for the objects?
  • a) Cache
  • b) ROM
  • c) HDD
  • d) RAM
Q.20
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
0 h : 0 m : 1 s