This is a sample program on encapsulation. Using encapsulation, here we find the characteristics of a cube. #include <iostream.h> #include <conio.h> class Cube { int side; int area, volume; public: void read() { cout<<" Enter The Side Of Cube: "; cin>>side; } void print() { cout<<" *********Characteristics Of Cube********* "<<'\n'; cout<<" Area: "<<6*side*side<<'\n'; cout<<" Volume: "<<side*side*side; } }; void main() { Cube C; C.read(); C.print(); getch(); } OUTPUT: Enter The Side Of Cube:9 *********Characteristics Of Cube********...
All HR and Technical interview questions with answers for freshers and experienced professional. It helps job seekers who are about to attend interviews.