C++ Object Oriented Programming Fundamentals

Test your knowledge of core Object Oriented Programming concepts in C++ including classes, objects, inheritance, polymorphism, encapsulation, and constructors/destructors.

24 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following is a special member function that is automatically called whenever an object of the class is destroyed?

  1. Constructor
  2. Destructor
  3. Delete operator
  4. Friend
  5. Member
Question 2 Multiple Choice (Single Answer)

A function call mechanism that passes arguments to a function by another name of arguments is

  1. call by value
  2. call by reference
  3. call by address
  4. call by value result
  5. default argument
Question 3 Multiple Choice (Single Answer)

In the given options which one is not a OOPs concept?

  1. Object
  2. Class
  3. Inheritence
  4. Pointer
  5. Polymorphism
Question 4 Multiple Choice (Single Answer)

In C++, which operator is used to access a global object or global data or static data member which is defined outside the class?

  1. : [Colon operator]
  2. :: [Scope resolution operator]
  3. . [Dot operator]
  4. -> [Arrow operator]
  5. & [Reference operator]
Question 5 Multiple Choice (Single Answer)

Which of the following is the valid class declaration header for the derived class A with base classes B and C?

  1. Class A : public B, public C
  2. Class A : public B, class C
  3. Class A : public B, C
  4. Class A : public B public C
  5. Class A : B C
Question 6 Multiple Choice (Single Answer)

Which of the following is not the characteristic of constructor?

  1. They do not have return type.
  2. They should be declared in the public section.
  3. They cannot be inherited.
  4. They can be virtual.
  5. They have the same name as name of class.
Question 7 Multiple Choice (Single Answer)

The process in which a class is defined within another class is called

  1. inheritance
  2. association
  3. encapsulation
  4. nesting of class
  5. binding class
Question 8 Multiple Choice (Single Answer)

If a class C is derived from class B, which is derived from class A, all through public inheritance, then this type of inheritance is called

  1. single inheritance
  2. hybrid inheritance
  3. hierarchical inheritance
  4. multilevel inheritance
  5. multiple inheritance
Question 9 Multiple Choice (Single Answer)

A constructor which takes arbitrary number of arguments is called

  1. default constructor
  2. parametrised constructor
  3. copy constructor
  4. multi constructor
  5. constructor overloading
Question 10 Multiple Choice (Single Answer)

A function that is declared within the base class, but redefined inside the derived class is called

  1. virtual function
  2. inline function
  3. constructor
  4. static member function
  5. non-public constructor
Question 11 Multiple Choice (Single Answer)

Which of the following is not the characteristics of a friend function?

  1. It can be declared both in the private and the public part of the class without altering the meaning.
  2. It is called using the object of the class.
  3. It does not belong to the class.
  4. It is invoked like a normal function.
  5. To access the data members of the class.
Question 12 Multiple Choice (Single Answer)

Which of the following is not the characteristics of a static data member?

  1. All the objects share the single copy of a static variable.
  2. Static data members are always used in the non static member functions.
  3. On the creation of the first object of the class a static variable is always initialised by zero.
  4. The scope is only within the class, but its lifetime is throughout the program.
  5. It can be accessed using their class names, the scope resolution operator and their member names.
Question 13 Multiple Choice (Single Answer)

Which of the following is not the characteristic of destructor?

  1. Destructor cannot be overloaded.
  2. Destructor can be inherited.
  3. It is not possible to take the address of a destructor.
  4. A destructor never accepts any argument nor does it return any value.
  5. A destructor is invoked implicitly by the compiler when we exit from the program or block.
Question 14 Multiple Choice (Single Answer)

Which visibility mode is used for data hiding in OOPs?

  1. Public
  2. Static
  3. Protected
  4. Private
  5. Virtual
Question 15 Multiple Choice (Single Answer)

If you want to open a file from initial position to the end of file, then which of the following modes is used?

  1. ios:app
  2. ios:trunc
  3. ios:ate
  4. ios:out
  5. ios:in
Question 16 Multiple Choice (Single Answer)

Encapsulation feature of OOPs __________ data from user.

  1. deletes
  2. hides
  3. formats
  4. shows
  5. destroys
Question 17 Multiple Choice (Single Answer)

A non-static function requires ___________ to access data.

  1. object
  2. class
  3. attribute
  4. data member
  5. member function
Question 18 Multiple Choice (Single Answer)

Which of the following is not true about abstract class?

  1. A class may inherit only one abstract class.
  2. Abstract classes are instantiated directly.
  3. An abstract class has at least one abstract method.
  4. An abstract class without any implementation just looks like an interface.
  5. Abstract classes are useful when creating hierarchies of classes that model reality.
Question 19 Multiple Choice (Single Answer)

The functions that change an object’s state or attributes are called

  1. manager functions
  2. auxiliary functions
  3. mutator functions
  4. predicate functions
  5. inspector functions
Question 20 Multiple Choice (Single Answer)

You have defined a class named Book that contains two non-static private fields, book_number and price. When you write a main () function and declare one Book object named Book1, you can display the object’s price field with the statement

  1. cout << Book.price;
  2. cout << Book(price);
  3. cout << Book1.price;
  4. cout << Book1(price);
  5. cout >> Book1.price;
Question 21 Multiple Choice (Single Answer)

A function or group of functions that differ in the types of parameters they use is called

  1. virtual function
  2. function template
  3. static funciton
  4. friend function
  5. inline function
Question 22 Multiple Choice (Single Answer)

A constructor is defined as Sum(int a = 10, float b = 10.0, char d = 'k'). Which of the following is a not legal statement that uses the constructor?

  1. Sum(1,1.0,'h')
  2. Sum(1)
  3. Sum(1,1.0)
  4. Sum('p')
  5. Sum(1.0)
Question 23 Multiple Choice (Single Answer)

Which of the following is not the characteristic of virtual function?

  1. Virtual functions are member functions of a class.
  2. Virtual function takes a different functionality in the derived class.
  3. Virtual functions are declared with the keyword virtual.
  4. Virtual functions are resolved during compile time.
  5. Virtual function is a mechanism to implement the concept of polymorphism.
Question 24 Multiple Choice (Single Answer)

The process of creating objects out of class is called

  1. initialisation
  2. instantiation
  3. assignment
  4. declaration
  5. loading