Mahindra Comviva Encapsulation Questions and Answers Quiz -1

Question 1

Time: 00:00:00
Which of the following options is true with regard to private and protected members of a class?

Both have the same properties with regard to an object of the class.

Both have the same properties with regard to an object of the class.

Private members cannot be directly accessed, while protected members can be directly accessed.

Private members cannot be directly accessed, while protected members can be directly accessed.

Protected members cannot be accessed by member functions, while private members can be accessed by member functions.

Protected members cannot be accessed by member functions, while private members can be accessed by member functions.

Private and protected members are same in all regards

Private and protected members are same in all regards

private members of a class like any private method can only be accessed by any other method in this class,not from a outside class method. But in case of any protected method the method can be accessed by a outside class method if the class is sub class of the accessed method class.

private members of a class like any private method can only be accessed by any other method in this class,not from a outside class method. But in case of any protected method the method can be accessed by a outside class method if the class is sub class of the accessed method class.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 2

Time: 00:00:00
which of the given options refers to data encapsulation in oops ?

The data and operation for an object are defined and fixed.

The data and operation for an object are defined and fixed.

Data of an object is encapsulated in its class

Data of an object is encapsulated in its class

Data is hidden for an object

Data is hidden for an object

A class can have multiple objects

A class can have multiple objects

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 3

Time: 00:00:00
There is a class which contains two integers as private members. There are two member functions (public) defined on it, one to add the two integers and another to subtract the two integers. Ravi wants to add a new functionality, which enables multiplication of the two numbers. Which one of the following options he should adopt?

He should define a third member function (public) which multiplies the two numbers.

He should define a third member function (public) which multiplies the two numbers.

He should define member functions (public) to return value of both the integers and then multiply them in his code. By returning the values, he can in future do any operation on them giving extensibility to the code.

He should define member functions (public) to return value of both the integers and then multiply them in his code. By returning the values, he can in future do any operation on them giving extensibility to the code.

He should define a third member function (private) which multiplies the two numbers.

He should define a third member function (private) which multiplies the two numbers.

He should define member functions (private) to return value of both the integers and then multiply them in his code. By returning the values, he can in future do any operation on them giving extensibility to the code.

He should define member functions (private) to return value of both the integers and then multiply them in his code. By returning the values, he can in future do any operation on them giving extensibility to the code.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 4

Time: 00:00:00
In c++ how are protected members of a base class accessed in derived class when inherited privately

Privately

Privately

Publicly

Publicly

Protectedly

Protectedly

Not Inherited

Not Inherited

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 5

Time: 00:00:00
Which of the following concepts means wrapping up of data and functions together?

Abstraction

Abstraction

Encapsulation

Encapsulation

Inheritance

Inheritance

Polymorphism

Polymorphism

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 6

Time: 00:00:00
Yukta created an interface to use it in different parts of the program by implementing it. But she forgot to specify the access specifier for each contained method. What will be the access specifier of the methods that will be inherited/implemented?

Public

Public

Private

Private

Protected

Protected

Will generate Error

Will generate Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 7

Time: 00:00:00
Which of the following options is true regarding Inheritance in Object-Oriented Programming?

There is reduced interaction with the hardware

There is reduced interaction with the hardware

A class may or may not have any object

A class may or may not have any object

Two or more functions can have the same name and same number and type of arguments in a program

Two or more functions can have the same name and same number and type of arguments in a program

Class-object relation can be changed at run time

Class-object relation can be changed at run time

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 8

Time: 00:00:00
Which of these is the functionality of Encapsulation?

Binds together code and data

Binds together code and data

Using single interface for general class of actions.

Using single interface for general class of actions.

Reduce Complexity

Reduce Complexity

All of the mentioned

All of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 9

Time: 00:00:00
How will a class protect the code inside it?

Using Access specifiers

Using Access specifiers

Abstraction

Abstraction

Use of Inheritance

Use of Inheritance

All of the mentioned

All of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

["0","40","60","80","100"]
["Need more practice! \r\n \r\n \r\n","Keep trying! \r\n \r\n \r\n","Not bad! \r\n \r\n \r\n","Good work! \r\n \r\n \r\n","Perfect! \r\n \r\n \r\n"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Comments