The site for java interview questions, Jobs for Freshers.High-Salary Jobs,C Interview,Java Codes,Java Books,Java Resumes,Java String,Quiz Test,C FAQ,Java Struts,Java EJB,Java JSP..net Interview questions,
RSS Feed (xml)
Skin Design: Free Blogger Skins
C++ Questions for Top Software Developing Companies with programs and solutions for 20081. What do you understand by visibility modes in class derivations? What are these modes?Ans. The visibility mode determines the availability of the members of a base class to the deriving class (and other classes, functions and the main function) from the derived class. There are three visibility modes:(i) Public (ii) Private (iii) Protected2. Define a class Teacher with the following class specification:private members:name 20 characterssubject 10 charactersBasic, DA, HRA floatsalary floatCalculate( ) function computes the salary and returns it.salary is sum of Basic, DA and HRApublic members:ReadData() function accepts the data values and invoke the calculate function.DisplayData() function prints the data on the screen.Ans.class Teacher{char name[20];char subject[10];float basic,da,hra;float salary;float calculate( ){return (basic+da+hra);}public:void readdata();void displaydata();};void Teacher::readdata(){cout<<"Enter Name:";gets(name);cout<<"Enter subject";gets(subject);cout<<"Enter Basic,DA,HRA:";cin>>basic>>da>>hra;salary=calculate();}void Teacher::displaydata(){cout<<"\nName:"<<cout<<"\nSubject:"<<cout<<"\nBasic:"<<<"\nDA:"<<<"\nHRA:"<<cout<<"\nSalary:"<<}3. Consider the following declarations and answer the questions given below:class vehicle{int wheels;protected:int passanger;public:void inputdata(int,int);void outputdata();};class heavy_vehicle:protected vehicle{int diesel_petrol;protected:int load;public:void readdata(int,int);void writedata();};class bus:private heavy_vehicle{char make[20];public:void fetchdata(char);void displaydata();};(i) Name the base class and derived class of the class heavy_vehicle.(ii) Name the data member(s) that can be accessed from function displaydata.(iii) Name the data member(s) that can be accessed by an object of bus class.(iv) Is the member function outputdata accessible to the objects of heavy_vehicle class?Ans.(i) Base class: vehicleDerived class: bus(ii) passanger, load, make(iii) No data members can be accessed by an object of bus class.(iv) No
Post a Comment
No comments:
Post a Comment