I was practicing inheritance in Java, and faced the following issue:
Code for parent class:
public class FEB7 {
String address,name;
void get(String n, String a){
name = n;
address = a;
}
void show(){
System.out.println("name is "+name);
System.out.println("address is " + address);
}
public static void main(String args[]) {
// compile time poly is method overloading, we will look at runtime poly
FEB7 obj = new FEB7();
obj.get("name1","address1");
obj.show();
} }
Code for child class:
public class FEB8 extends FEB7 {
String regno;
void get(String r) {
regno = r;
}
void showreg() {
System.out.println("regno is " + regno);
}
public static void main(String args) {
FEB8 obj1 = new FEB8();
obj1.get("name2", "address2");
obj1.get("regno1");
obj1.show();
obj1.showreg();
}}
Both are separate .java files. When i try to execute the parent class file, it works but for some reason i cannot even run the child class. The following message is there:
The file FEB8.java is not executable. please select a main class you want to run
How do i solve this issue?
>Solution :
The main method in FEB8 has String args as the argument instead of String args[]. Change it to args[] and try again.