Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
2.3k views
in General by (120k points)
closed by
Find which of the following uses encapsulation?

(a) void main(){  int a;  void fun( int a=10;  cout<<a); fun(); }

(b) class student{ int a;   public: int b;};

(c) class student{int a; public: void disp(){ cout<<a;} };

(d) struct topper{ char name[10]; public : int marks; }

1 Answer

0 votes
by (120k points)
selected by
 
Best answer
The correct option is (c) class student{int a; public: void disp(){ cout<<a;} };

The explanation is: It is the class which uses both the data members and member functions being declared inside a single unit. Only data members can be there in structures also. And the encapsulation can only be illustrated if some data/operations are associated within class.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...