0

OOPs (NCO)

Description: It contains basic concepts of OOPs.
Number of Questions: 25
Created by:
Tags: OOPs C
Attempted 0/25 Correct 0 Score 0

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


Correct Option: B
Explanation:

Destructor is a special member function that is automatically called whenever an object of the class is destroyed.

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


Correct Option: B
Explanation:

Call by reference mechanism uses another name of arguments.

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

  1. Object

  2. Class

  3. Inheritence

  4. Pointer

  5. Polymorphism


Correct Option: D
Explanation:

It is not an OOPs concept.

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]


Correct Option: B
Explanation:

This operator is used to access a global object or global data or static data member.

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


Correct Option: A
Explanation:

This is the correct declaration according to syntax rule.

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.


Correct Option: D
Explanation:

This is not the characteristic of constructor.

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


Correct Option: D
Explanation:

The process in which a class is defined within another class is called nesting of 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

  1. single inheritance

  2. hybrid inheritance

  3. hierarchical inheritance

  4. multilevel inheritance

  5. multiple inheritance


Correct Option: D
Explanation:

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 multilevel inheritance.

 

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


Correct Option: C
Explanation:

Copy constructor takes one argument.

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


Correct Option: A
Explanation:

A virtual function is a member function that is declared within the base class, but redefined inside the derived class.

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.


Correct Option: B
Explanation:

It is not the characteristics of a friend function, since it is not called using the object of the class.

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.


Correct Option: B
Explanation:

It is not the characteristic of static data member because static data members are always used in the static member functions.

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.


Correct Option: B
Explanation:

It is not the characteristic of destructor because it cannot be inherited.

Which visibility mode is used for data hiding in OOPs?

  1. Public

  2. Static

  3. Protected

  4. Private

  5. Virtual


Correct Option: D
Explanation:

Private visibility mode is used for data hiding.

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


Correct Option: C
Explanation:

This mode is used for initial position to end of file.

Which of the following defines an instance of class disk?

  1. Disk

  2. RedBowl

  3. Wash

  4. Colour

  5. Fill


Correct Option: B
Explanation:

RedBowl defines an instance of class disk.

Encapsulation feature of OOPs __________ data from user.

  1. deletes

  2. hides

  3. formats

  4. shows

  5. destroys


Correct Option: B
Explanation:

Encapsulation feature of OOPs hides data from the user.

A non-static function requires ___________ to access data.

  1. object

  2. class

  3. attribute

  4. data member

  5. member function


Correct Option: A
Explanation:

A non-static function requires object to access data.

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.


Correct Option: B
Explanation:

This is not true about abstract class because abstract classes are not instantiated directly.

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


Correct Option: C
Explanation:

Mutator functions, also known as implementors, are functions that change an object’s state or attributes.

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;


Correct Option: C
Explanation:

This is the correct statement to display the object’s price field.

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


Correct Option: B
Explanation:

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

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)


Correct Option: D
Explanation:

This is not a legal statement that uses the constructor because when it runs, it gives an incorrect 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.


Correct Option: D
Explanation:

It is not the characteristic of virtual function because virtual functions are resolved during run time.

The process of creating objects out of class is called

  1. initialisation

  2. instantiation

  3. assignment

  4. declaration

  5. loading


Correct Option: B
Explanation:

The process of creating objects out of class is called instantiation.

- Hide questions