Question
class student
{
int marks;
public : int* fun()
{
return &marks;
}
};
main()
{
student s;
int *ptr=c.fun();
return 0;
}
a.
This code is good to go
b.
This code may result in undesirable conditions
c.
This code will generate error
d.
This code violates encapsulation
Posted under Object Oriented Programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. Consider the following code and select the correct option:
Similar Questions
Discover Related MCQs
Q. Encapsulation is the way to add functions in a user defined structure.
View solution
Q. Using encapsulation data security is ___________
View solution
Q. Which among the following best defines abstraction?
View solution
Q. Hiding the implementation complexity can:
View solution
Q. Class is _________ abstraction
View solution
Q. Object is ________ abstraction
View solution
Q. Abstraction gives higher degree of ________
View solution
Q. Abstraction can apply to:
View solution
Q. Which among the following can be viewed as combination of abstraction of data and code.
View solution
Q. Abstraction principle includes___________
View solution
Q. Higher the level of abstraction, higher are the details.
View solution
Q. Encapsulation and abstraction differ as:
View solution
Q. In terms of stream and files________
View solution
Q. If two classes combine some private data members and provides public member functions to access and manipulate those data members. Where is abstraction used?
View solution
Q. A phone is made up of many components like motherboard, camera, sensors and etc. If the processor represents all the functioning of phone, display shows the display only, and the phone is represented as a whole. Which among the following have highest level of abstraction?
View solution
Q. Which among the following is not a level of abstraction:
View solution
Q. Using higher degree of abstraction __________
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!