0

Oops

Description: This test contains questions on c++
Number of Questions: 15
Created by:
Tags: programming Java/Oracle /C/C++
Attempted 0/15 Correct 0 Score 0

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


Correct Option: C
Explanation:

Abstraction refers to the act of hiding actual details from the user. 

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;}


Correct Option: A
Explanation:

This is the correct syntax of declaring a class and members of the class.

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.


Correct Option: D
Explanation:

All the above four, except this option, are correct about a class.

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


Correct Option: B
Explanation:

In OOPS, the variables which we use in a class are known as data members.

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


Correct Option: A
Explanation:

It is one of the classic features which leads to the idea of re-usability.

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


Correct Option: E
Explanation:

Operator overloading is a feature to give new meaning to the existing operator.

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


Correct Option: D
Explanation:

This is incorrect.

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.


Correct Option: C
Explanation:

This is incorrect.

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)


Correct Option: E
Explanation:

Options (1) and (2) correctly explain the reason.

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)


Correct Option: E
Explanation:

Correct

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


Correct Option: A
Explanation:

He may use the syntax given below: class name:access specifier classname

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


Correct Option: C
Explanation:

A constructor is a member function whose task is to initialise the values for objects as they are created.

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


Correct Option: C
Explanation:

The friend function is always declared outside any class by using friend keyword.

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.


Correct Option: C
Explanation:

Both errors are displayed in this program.

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


Correct Option: B
Explanation:

This is the correct syntax. 

- Hide questions