KnowledgeBoat Logo
|

Computer Applications

Write a class specifier (along with its constructor) that creates a class student having two private data members : rollno and grade and two public functions init( ) and display( ).
(Do not write full definitions of member functions except for constructor).

Java Constructors

12 Likes

Answer

class student
{
    private int rollno;
    private char grade;

    public student()    {
        rollno = 0;
        grade = '\0';
    }

    public student(int roll, char g)
    {
        rollno = roll;
        grade = g;
    }

    public void init()  {}
    
    public void display()   {}
}

Answered By

8 Likes


Related Questions