Answer:
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