Ask Question
30 October, 04:13

Person-name: String+setName (String name) : void+getName () : String^Student-studentID: long+Student (String sname, long sid) + setID () : longWhich of these fields or methods are inherited (and accessible) by the Student class?

1. getName (), setName (), name

2. name, getName (), setName (), getID ()

3. studentID, name, getName (), setName (), getID ()

4. getName (), setName (), toString ()

5. None of them

6. getName (), setName (), studentID, getID ()

+5
Answers (1)
  1. 30 October, 04:44
    0
    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

    #include

    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 = " <
    cout<<"Name=" <
    cout <<"Grade = "<< grade <
    }

    };

    void main ()

    {

    clrscr ();

    Student s1 (730,'A','ali') s2 (621,'B','haider')

    cout <<"Recording of student 1 "<
    s1. set ();

    cout <<"Recording of Student 2:"<
    s2. set ();

    getch ();

    }

    for the above program you can see from

    //{

    cout <<"Marks = " <
    cout<<"Name=" <
    cout <<"Grade = "<< grade <
    }//

    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Person-name: String+setName (String name) : void+getName () : String^Student-studentID: long+Student (String sname, long sid) + setID () : ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers