A simple java program using class and object


In this program, You will learn how to create a simple java program using class and object.


obj.msg();

obj.display();

Example: How to create a simple java program using class and object.

class Test {

    void msg() {
        System.out.println("Msg method is called here");
    }

    void display() {
        System.out.println("Display method is called here");
    }
}

class Main {

    public static void main(String args[]) {

        Test obj = new Test();
        obj.msg();
        obj.display();
    }
}

Output:

Msg method is called here
Display method is called here