program of parameterized constructor

Program of parameterized constructor
class test
{
int eid;
String ename;
test(int i,String n)
{
eid = i;
ename = n;
}
void display()
{
System.out.println(eid+” “+ename);
}
public static void main(String args[])
{
test t1 = new test(1,”adam”);
test t2 = new test(2,”voges”);
t1.display();
t2.display();
}
}

Output:
1 adam
2 voges

Leave a Reply

Your email address will not be published. Required fields are marked *