Answer and Explanation:
Basically its answer is option 4 where getName(), setName().to String()
let us explained it through a program where get and set method has been used.
Create Student class that has marks and grade. Two parameters initialize data member using constructors .Each data member gives values and member function .Show the values of data member.
You can code it in turbo and Dev C++ tool .
# include<iostream.h>
#include<conio.h>
class Student
{
private:
int marks;
String name;
char grade;
public:
Student ( int m , char g) //get method where it get student marks and grade
{ marks = m ;
grade = g;
}
public void set Name(String a) {
name = a;
}
public String getName() {
return name;
}
void set()
{
cout <<"Marks = " <<marks <<endl;
cout<<"Name=" <<name<<endl;
cout <<"Grade = "<< grade <<endl;
}
};
void main ()
{
clrscr();
Student s1(730,'A','ali') s2(621,'B','haider')
cout <<"Recording of student 1 "<<endl;
s1.set();
cout <<"Recording of Student 2:"<<endl;
s2.set();
getch();
}
for the above program you can see from
//{
cout <<"Marks = " <<marks <<endl;
cout<<"Name=" <<name<<endl;
cout <<"Grade = "<< grade <<endl;
}//
where name marks and grade are inherited from the class Student with get and set methods.But name is take into data type of string because string hold zero ,more letters , space and commas.So it is used to represent the text data.