Object Oriented Programming Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Anima.jain18
A
Anima.jain18
Community Contributor
Quizzes Created: 1 | Total Attempts: 495
| Attempts: 495 | Questions: 20
Please wait...
Question 1 / 20
0 %
0/100
Score 0/100
1. Which of the following statement is correct?

Explanation

The correct answer is "Object is an instance of a class." In object-oriented programming, a class is a blueprint for creating objects. An object is an instance of a class, meaning it is created based on the definition provided by the class. Each object created from a class has its own set of properties and behaviors defined by the class. Therefore, an object is an instance of a class.

Submit
Please wait...
About This Quiz
Object Oriented Programming Quiz - Quiz

This Object Oriented Programming Quiz assesses key concepts such as composition, object usage, constructors, singleton classes, and dynamic binding in C++. It is designed to enhance understanding and... see moreapplication skills in OOP, crucial for software development. see less

2. Which of the following is an abstract data type?

Explanation

An abstract data type is a data type that is defined by the behavior it exhibits rather than the specific implementation details. It provides a set of operations that can be performed on the data without revealing the internal representation. A class in programming languages like Java or C++ is an example of an abstract data type because it encapsulates data and functions/methods that operate on that data, providing a way to create objects and manipulate them.

Submit
3. Which of the following provides a reuse mechanism?

Explanation

Inheritance provides a reuse mechanism in object-oriented programming. It allows a class to inherit properties and behaviors from another class, known as the parent or base class. This enables the derived class to reuse the code and functionality of the base class, reducing code duplication and promoting code reusability. Inheritance also supports the concept of polymorphism, where objects of derived classes can be treated as objects of the base class, providing flexibility and extensibility in the design of software systems.

Submit
4. Which of the following operator is overloaded for object cout?

Explanation

The

Submit
5.
What happens if the base and derived class contains definition of a function with same prototype?

Explanation

When both the base and derived classes contain a function with the same prototype, the function in the derived class overrides the function in the base class. This means that when a base class object calls the function, it will call the base class function, and when a derived class object calls the function, it will call the derived class function. This is known as function overriding.

Submit
6. Which of the following is not a type of constructor?

Explanation

A friend constructor is not a type of constructor. In object-oriented programming, a constructor is a special method that is used to initialize objects of a class. It is called automatically when an object is created. The copy constructor creates a new object by copying the values of an existing object. The default constructor is a constructor that takes no arguments. The parameterized constructor is a constructor that takes one or more parameters. However, a friend constructor is not a recognized type of constructor.

Submit
7.
Which of the following type of class allows only one object of it to be created?

Explanation

A Singleton class allows only one object of it to be created. This is achieved by making the constructor of the class private, so that it cannot be accessed from outside the class. The class itself provides a static method that returns the instance of the class, and this method ensures that only one instance is created and returned. This pattern is commonly used in scenarios where there should be only one instance of a class, such as a database connection or a logger.

Submit
8. How many types of polymorphisms are supported by C++?

Explanation

C++ supports two types of polymorphisms: compile-time polymorphism and runtime polymorphism. Compile-time polymorphism is achieved through function overloading and template specialization, where different functions or templates with the same name but different parameters or template arguments are used. Runtime polymorphism is achieved through virtual functions and inheritance, where a base class pointer can point to objects of different derived classes, allowing for dynamic dispatch of function calls based on the actual type of the object being referred to.

Submit
9. Which of the following is not a type of inheritance?

Explanation

Distributive inheritance is not a recognized type of inheritance in object-oriented programming. The other options listed - multiple, multilevel, and hierarchical - are all valid types of inheritance. Multiple inheritance refers to a class inheriting from multiple parent classes, multilevel inheritance refers to a class inheriting from a derived class, and hierarchical inheritance refers to a class inheriting from a single parent class. However, distributive inheritance is not a commonly used or recognized term in the context of inheritance.

Submit
10. Which of the following concepts means determining at runtime what method to invoke?

Explanation

Dynamic binding refers to the process of determining at runtime which method to invoke based on the actual type of the object. This allows for polymorphism, where different objects of different classes can be treated as objects of a common superclass and their specific methods can be called based on their actual types. Dynamic binding is an important concept in object-oriented programming as it enables flexibility and extensibility in the code.

Submit
11.
How "Late binding" is implemented in C++?

Explanation

Late binding in C++ is implemented using virtual tables. A virtual table, also known as a vtable, is a lookup table of function pointers used to implement dynamic dispatch. When a class has virtual functions, a vtable is created for that class, which contains pointers to the virtual functions. During runtime, when a virtual function is called through a base class pointer, the vtable is used to determine the correct function to be called based on the actual object type. This allows for the implementation of polymorphism and enables late binding, where the function to be called is determined at runtime.

Submit
12. Which of the following ways are legal to access a class data member using this pointer?

Explanation

The correct answer is "this->x". In C++, the "this" pointer is a special pointer that points to the object itself. By using the "->" operator, we can access the data member "x" of the current object. The "->" operator is used to access members of an object through a pointer. Therefore, "this->x" is the correct way to access a class data member using the "this" pointer.

Submit
13. What is correct about the static data member of a class?

Explanation

A static member function can access only static data members of a class because static member functions do not have access to the non-static members of a class. A static data member is shared among all the objects of the class, meaning that any changes made to the static data member will be reflected in all instances of the class. This allows for the sharing of data between different objects of the same class.

Submit
14. Which of the following statements is correct in C++?

Explanation

In C++, structures can have functions as members. This is a key difference between structures and classes in C++. While both structures and classes can have data members, only structures can have functions as members. This allows for more flexibility in organizing and defining data and functions within a structure.

Submit
15.
cout is a/an __________ .

Explanation

The correct answer is "object" because "cout" is an object in C++. It is an instance of the "ostream" class and is used to display output on the console.

Submit
16.
Which of the following access specifier is used as a default in a class definition?

Explanation

In a class definition, the access specifier that is used as a default is "private". This means that the members of the class, such as variables and methods, can only be accessed within the class itself and not from outside the class or its subclasses. It provides the highest level of encapsulation and data hiding, ensuring that the internal implementation details of the class are not exposed to other parts of the program.

Submit
17. Which of the following are available only in the class hierarchy chain?

Explanation

Protected data members are available only in the class hierarchy chain. This means that they can be accessed by the class in which they are defined, as well as by any derived classes. Protected data members are not accessible by objects of the class or by functions outside the class hierarchy chain. This access level provides a balance between the strict encapsulation of private data members and the complete accessibility of public data members.

Submit
18.
Which of the following concepts provides facility of using object of one class inside another class?

Explanation

Composition is a concept in object-oriented programming that allows for the use of objects of one class inside another class. This means that one class can contain an instance of another class as a member variable. This allows for a strong relationship between the two classes, where the inner class is an essential part of the outer class. This concept promotes code reusability and modular design by allowing objects to be composed of other objects.

Submit
19. Which of the following is the correct way of declaring a function as constant?

Explanation

The correct way of declaring a function as constant is by using the "const" keyword after the closing parenthesis of the function declaration. This ensures that the function does not modify any member variables of the class in which it is defined. In this case, the correct answer is "int ShowData(void) const { /* statements */ }".

Submit
20. Which of the following is correct about the statements given below?
  1. All operators can be overloaded in C++.
  2. We can change the basic meaning of an operator in C++.

Explanation

In C++, not all operators can be overloaded. Some operators, such as the dot operator (.), the scope resolution operator (::), the ternary operator (?:), and the sizeof operator, cannot be overloaded. Therefore, statement 1 is false. Additionally, while operator overloading allows us to change the behavior of an operator, it does not change its basic meaning. The basic meaning of an operator remains the same, but we can define new behavior for the operator when it is used with user-defined types. Therefore, statement 2 is also false.

Submit
View My Results

Quiz Review Timeline (Updated): May 27, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • May 27, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 10, 2020
    Quiz Created by
    Anima.jain18
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following statement is correct?
Which of the following is an abstract data type?
Which of the following provides a reuse mechanism?
Which of the following operator is overloaded for object cout?
What happens if the base and derived class contains definition of a...
Which of the following is not a type of constructor?
Which of the following type of class allows only one object of it to...
How many types of polymorphisms are supported by C++?
Which of the following is not a type of inheritance?
Which of the following concepts means determining at runtime what...
How "Late binding" is implemented in C++?
Which of the following ways are legal to access a class data member...
What is correct about the static data member of a class?
Which of the following statements is correct in C++?
Cout is a/an __________ .
Which of the following access specifier is used as a default in a...
Which of the following are available only in the class hierarchy...
Which of the following concepts provides facility of using object of...
Which of the following is the correct way of declaring a function as...
Which of the following is correct about the statements given below? ...
Alert!

Advertisement