Showing posts with label Object of Student Class is created in main Method. Show all posts
Showing posts with label Object of Student Class is created in main Method. Show all posts

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();

                                               }

}