- //Student Class for Practice
- class Student
- {
- int rollno;
- String name;
- void insertRecord(int rno, String na)
- {
- rollno=rno;
- name=na;
- }
- void displayInformation()
- {
- System.out.println("Student Details: "+rollno+" "+name);
- }
- }
- class TestStudent
- {
- public static void main(String args[])
- {
- Student s1=new Student();
- Student s2=new Student();
- s1.insertRecord(302,"Dinesh");
- s2.insertRecord(348,"Geetheswar");
- s1.displayInformation();
- s2.displayInformation();
- }
- }
This comment has been removed by the author.
ReplyDelete
ReplyDeleteclass Animal
{
String name;
int alive;
int existance;
void insert(String na,int a,int ex)
{
name=na;
alive =a;
existance=ex;
}
void display()
{
System.out.println("name of Animal:"+name+"\nno of alive:"+alive+"\nno of existance:"+existance);
}
void totalAlive()
{
float totalAlive=alive/existance;
System.out.println("TotalAlive="+totalAlive);
}
}
class AnimalTest {
public static void main(String[] args)
{
Animal A1=new Animal();
Animal A2=new Animal();
A1.insert("green_anakonda",2300,999);
A2.insert("riyon",1500,458);
A1.display();
A2.display();
A1.totalAlive();
A2.totalAlive();
}
}