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());
}
}
Asked
Active
Viewed 45 times
-1

rioV8
- 24,506
- 3
- 32
- 49

Jawad Khan
- 17
- 3
-
1There is no main method in Base. Only MyClass has main. – NomadMaker Jan 16 '21 at 17:39
-
1Not enough research effort – HoRn Jan 16 '21 at 17:42
-
1Does this answer your question? [What does "Could not find or load main class" mean?](https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean) – Jan 16 '21 at 20:00
1 Answers
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
- 188
- 1
- 11