Tuesday, 2 August 2011

Constructor- Is a Function which is Automatically called when Object is created using new operator

class Student extends Human{
  int RollNo;
 String ClassName;

 Student(){

System.out.println("I am constructor of Student Class");
}

public void setRollNo(int r){
RollNo=r;
}
public int getRollNo(){
return RollNo;
}


public void setClassName(String s){
ClassName=s;
}
public String getClassName(){
return ClassName;
}

public static void main(String agr[]){
                new Student();

                                               }

}

No comments:

Post a Comment