Saturday 30 July 2011

Caller Class will use both Classes Object in Main Method


class Caller{
public static void main(String m[]){
//The commented code can be run  by removing the // sign from each line
//String myname;
//int myage;
//Human h=new Human();
//h.setAge(20);
//h.setName("Mamoon");
//System.out.println("Your age"+h.Age+"\n"+"your Name"+h.Name);
//System.out.println(h.getAge());
//System.out.println(h.getName());
//myage=h.getAge();
//myname=h.getName();
//System.out.println("Age:"+myage+"\n"+"Name:"+myname);

    Student s =new  Student();
      s.Age=32;
     int x= s.getAge();
   System.out.println("Age:"+x);

}// end of void
}//end of main

No comments:

Post a Comment