Creating class and Object
Here you can see how class and object are created.
class Emp
{
int empno; //Instance variables
String name;
float sal;
void input(int eno,String ename,float esal) //Methods
{
empno=empno;
name=ename;
sal=esal;
}
void show()
{
System.out.println("Empno is"+empno);
System.out.println("Name is "+name);
System.out.println("Sal is "+sal);
}
public static void main(String args[])
{
Emp ram=new Emp(); //Creating a new object, a new operator is used to
allocate a memory for the object.
//ram is an object of Class Emp.
ram.input(1001,"Ram ", 9090.0f);
ram.show();
Emp shyam =new Emp();
shyam.input(1002,"Shyam",8888.0f);
shyam.show();
}
}


