Wednesday, 4 September 2013

class / objec and method in java

class Student{

    int no=10;    // data members

    void display(){  // method
        System.out.println("Hai!");
    }
}

class Main_Student{
public static void main(String args[]){
   
    Student s = new Student(); //object s for Student class
   
    System.out.println("Student number is:" +s.no);
    s.display();
    System.out.println("This is main class!");   
    }
}