-1
package myjavacode;

// using vs code to run program

class Base{                            

   int x;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        System.out.println("I am in base setting x now");
        this.x = x;
    }
}

class Derived extends Base{}


public class MyClass {
    public static void main(String[] args) {

        System.out.println("Hello World");

        Derived obj = new Derived();
        obj.setX(4);
        System.out.println(obj.getX());
    }
}
rioV8
  • 18,123
  • 3
  • 18
  • 35
Jawad Khan
  • 15
  • 2

1 Answers1

0

Java main method is the entry point of any java program. so you can not run any class without this entry point, it seems you are trying to run the code from the Base class which do not have this main method.

public static void main(String[] args)
Shadi Jumaa
  • 165
  • 11