What will happen when calling a static method using an object?

Last Updated :
Discuss
Comments

What will happen when calling a static method using an object?

Java
class Demo {
    static void show() {
        System.out.println("Static Method");
    }
    public static void main(String[] args) {
        Demo obj = new Demo();
        obj.show();
    }
}


Compilation error


Static Method

NullPointerException

Runtime error

Share your thoughts in the comments