C++ Object Oriented Programming

This quiz covers fundamental concepts of Object Oriented Programming in C++, including classes, objects, inheritance, polymorphism, encapsulation, constructors, and access specifiers.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

In an office, a clerk builds a logic using C++ to calculate salary of the employees, which is hidden from the other employees. Which feature of the language is he using?

  1. Inheritance
  2. Encapsulation
  3. Abstraction
  4. Class
  5. None of these
Question 2 Multiple Choice (Single Answer)

Which of the following is the correct syntax of declaring a class in C++?

  1. class classname {varibale declaration function declaration};
  2. class {variables; function;};
  3. class classname{variables function};
  4. class classname;{ };
  5. class classname {member variables; member function;}
Question 3 Multiple Choice (Single Answer)

Which of the following statements is incorrect about classes in object oriented programming?

  1. A class is a user defined data-type.
  2. A class provides mechanism to hold data and function at one place.
  3. It incorporates security in programming.
  4. The member of a class can be accessed by any function.
  5. A class is a logical concept. In real world, objects exist physically.
Question 4 Multiple Choice (Single Answer)

Identify the data member or the member variables in the above program.

class A
{
public: int a;
void display()
{
cout<<"Enter the value in a";
cin>>a;
}
};
void main()
{
A a1; a1.display();
getch();
}

  1. a1 is the data member of class A.
  2. a is the data member of class A.
  3. Display is the data member in class A.
  4. Both a and d together are data members in class A.
  5. None of these
Question 5 Multiple Choice (Single Answer)

A company launched a new car by adding or modifying some features in an existing car. Which feature of OOPS is implemented by the company?

  1. Inheritance
  2. Encapsulation
  3. Abstraction
  4. Operator overloading
  5. Public
Question 6 Multiple Choice (Single Answer)

Which of the following operators is used in C++ to implement operator overloading?

  1. Scope resolution operator
  2. Structure reference
  3. Ternary condition
  4. Size of
  5. Addition operator
Question 7 Multiple Choice (Single Answer)

Which of the followng statements is incorrect about private access specifiers in C++?

  1. It prevents the misuse of data.
  2. It provides security to the data member.
  3. It creates a boundary for the members of a class.
  4. The member which is declared privately can be accessed by any other function in a class.
  5. None of these
Question 8 Multiple Choice (Single Answer)

Which of the following statements is incorrect about objects in C++?

  1. An object is a type of a certain class.
  2. Objects are real world entities.
  3. Objects are not implemented in C++.
  4. Objects are used to invoke member function of a class.
  5. Objects use message passing to communicate with each other.
Question 9 Multiple Choice (Single Answer)

In the above program, which is/are the possible reason(s) for not generating the output?

Class A
{
public: void display()
{
printf("This is class A");
}
};
void main()
{
A a1; a1.display();
getch();
}

  1. Use of printf in class A
  2. C++ use cout<< operator to display the text on screen.
  3. Function definition can always be done outside the class.
  4. Function calling can be done by using the name of the function.
  5. Both (1) and (2)
Question 10 Multiple Choice (Single Answer)

How will you resolve ambiguity between functions in C++?

  1. C++ uses the scope resolution operator to resolve ambiguity between functions.
  2. C++ supports function overloading to resolve ambiguity.
  3. Each function is unique in C++.
  4. C++ does not provide any mechanism to resolve function ambiguity.
  5. Both (1) and (2)
Question 11 Multiple Choice (Single Answer)

A person creates a class with the name 'A' in C++. He wishes to use the features of this class in class B. Which syntax will he use to implement this?

  1. class B:public/protected/private A
  2. class B inherits class A
  3. class B extends A
  4. class B:class A
  5. class B inherited A
Question 12 Multiple Choice (Single Answer)

Name a function in C++ which provides initial values to the objects.

  1. Member function
  2. Friend function
  3. Constructor
  4. Destructor
  5. None of these
Question 13 Multiple Choice (Single Answer)

In which section of the program will you declare a friend function for the class?

  1. Private
  2. Public
  3. Outside class definition with keyword friend
  4. Inside class definition
  5. None of these
Question 14 Multiple Choice (Single Answer)

Which of the following error messages is/are displayed to the user if the user improperly writes a header file in the above program? (Turbo C++)

#include"iostrem.h"
#include"conio.h"
void main()
{
cout<<"hi";
getch();
}

  1. Unable to open include file iosteam.h
  2. Undefined symbol cout
  3. Both (1) and (2)
  4. The program will compile and execute normally.
  5. It will give a warning to the user.
Question 15 Multiple Choice (Single Answer)

How will you implement multiple inheritance in C++?

  1. class B, class C:public A
  2. class B:public A
    class C:public A
  3. class B:public C
    class C:public A
  4. Multiple inheritance is not supported in C++.
  5. class A:public B
    class B:public A