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.
Questions
Which of the following is a special member function that is automatically called whenever an object of the class is destroyed?
- Constructor
- Destructor
- Delete operator
- Friend
- Member
A function call mechanism that passes arguments to a function by another name of arguments is
- call by value
- call by reference
- call by address
- call by value result
- default argument
In the given options which one is not a OOPs concept?
- Object
- Class
- Inheritence
- Pointer
- Polymorphism
In C++, which operator is used to access a global object or global data or static data member which is defined outside the class?
- : [Colon operator]
- :: [Scope resolution operator]
- . [Dot operator]
- -> [Arrow operator]
- & [Reference operator]
Which of the following is the valid class declaration header for the derived class A with base classes B and C?
- Class A : public B, public C
- Class A : public B, class C
- Class A : public B, C
- Class A : public B public C
- Class A : B C
Which of the following is not the characteristic of constructor?
- They do not have return type.
- They should be declared in the public section.
- They cannot be inherited.
- They can be virtual.
- They have the same name as name of class.
The process in which a class is defined within another class is called
- inheritance
- association
- encapsulation
- nesting of class
- binding class
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
- single inheritance
- hybrid inheritance
- hierarchical inheritance
- multilevel inheritance
- multiple inheritance
A constructor which takes arbitrary number of arguments is called
- default constructor
- parametrised constructor
- copy constructor
- multi constructor
- constructor overloading
A function that is declared within the base class, but redefined inside the derived class is called
- virtual function
- inline function
- constructor
- static member function
- non-public constructor
Which of the following is not the characteristics of a friend function?
- It can be declared both in the private and the public part of the class without altering the meaning.
- It is called using the object of the class.
- It does not belong to the class.
- It is invoked like a normal function.
- To access the data members of the class.
Which of the following is not the characteristics of a static data member?
- All the objects share the single copy of a static variable.
- Static data members are always used in the non static member functions.
- On the creation of the first object of the class a static variable is always initialised by zero.
- The scope is only within the class, but its lifetime is throughout the program.
- It can be accessed using their class names, the scope resolution operator and their member names.
Which of the following is not the characteristic of destructor?
- Destructor cannot be overloaded.
- Destructor can be inherited.
- It is not possible to take the address of a destructor.
- A destructor never accepts any argument nor does it return any value.
- A destructor is invoked implicitly by the compiler when we exit from the program or block.
Which visibility mode is used for data hiding in OOPs?
- Public
- Static
- Protected
- Private
- Virtual
If you want to open a file from initial position to the end of file, then which of the following modes is used?
- ios:app
- ios:trunc
- ios:ate
- ios:out
- ios:in
Encapsulation feature of OOPs __________ data from user.
- deletes
- hides
- formats
- shows
- destroys
A non-static function requires ___________ to access data.
- object
- class
- attribute
- data member
- member function
Which of the following is not true about abstract class?
- A class may inherit only one abstract class.
- Abstract classes are instantiated directly.
- An abstract class has at least one abstract method.
- An abstract class without any implementation just looks like an interface.
- Abstract classes are useful when creating hierarchies of classes that model reality.
The functions that change an object’s state or attributes are called
- manager functions
- auxiliary functions
- mutator functions
- predicate functions
- inspector functions
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
- cout << Book.price;
- cout << Book(price);
- cout << Book1.price;
- cout << Book1(price);
- cout >> Book1.price;
A function or group of functions that differ in the types of parameters they use is called
- virtual function
- function template
- static funciton
- friend function
- inline function
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?
- Sum(1,1.0,'h')
- Sum(1)
- Sum(1,1.0)
- Sum('p')
- Sum(1.0)
Which of the following is not the characteristic of virtual function?
- Virtual functions are member functions of a class.
- Virtual function takes a different functionality in the derived class.
- Virtual functions are declared with the keyword virtual.
- Virtual functions are resolved during compile time.
- Virtual function is a mechanism to implement the concept of polymorphism.
The process of creating objects out of class is called
- initialisation
- instantiation
- assignment
- declaration
- loading