Ask Question
Today, 11:28

Write a Student class in Java which has a name, id_number, year (e. g. 2) and

programme_code (e. g. ECE) as member variables. Add a constructor to your class

and a display () method, which prints out all information relating to a Student.

+1
Answers (1)
  1. Today, 11:44
    0
    Following are the code in java

    public class Student

    {

    / / member variables

    String name;

    String id_number;

    int year;

    String programme_code;

    / / default constructor

    public student () / /default constructor

    {

    name="san";

    id_number="12";

    year = 2010;

    programme_code="ECE";

    }

    / / method to display the member variables of the Student

    public void display () / / dispaly the value

    {

    System. out. println ("Name is : "+name);

    System. out. println ("ID is : "+id_number);

    System. out. println ("Year is : "+year);

    System. out. println ("Programme code is : "+programme_code);

    }

    public static void main (String[] args) / / Main method

    {

    Student ob=new Student ();

    ob. display (); / / calling the method display

    }

    }

    Explanation:

    In this we create a class "student " name, id_number, year and programme_code are the variable after that create a default constructor and initialize the variable and finally display the variable. In the main method we create a object of student class i. e ob, and call display method with object ob.

    Output:

    Name is : san

    ID is : 12

    Year is : 2010

    Programme code is : ECE
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a Student class in Java which has a name, id_number, year (e. g. 2) and programme_code (e. g. ECE) as member variables. Add a ...” 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