P4.2 USING METHOD TO DISPLAY INFORMATION
class Student
{
int rollno;
String name;
void insertRecord(int r, String n)
{
rollno=r;
name=n;
}
void displayInfo()
{
System.out.println(rollno+" "+name);
}
}
class TestStudent
{
public static void main(String args[])
{
Student s1=new Student();
Student s2=new Student();
s1.insertRecord(11,"ABCD");
s2.insertRecord(22,"EFGH");
s1.displayInfo();
s2.displayInfo();
}
}
{
int rollno;
String name;
void insertRecord(int r, String n)
{
rollno=r;
name=n;
}
void displayInfo()
{
System.out.println(rollno+" "+name);
}
}
class TestStudent
{
public static void main(String args[])
{
Student s1=new Student();
Student s2=new Student();
s1.insertRecord(11,"ABCD");
s2.insertRecord(22,"EFGH");
s1.displayInfo();
s2.displayInfo();
}
}
Comments
Post a Comment