[Solved] How to call another classes super class? [closed]

[ad_1]

Yes. Assuming the classes remain in the same package – x.getVal will work.

class A {
  String getVal(){
    return "from a";
  }
}
class B extends A {

}
public class C {
  public static void main(String [] args) {
    B x = new B();
    x.getVal();
  }
}

It works – because of the default access modifier. Use the protected access modifier for inheritance.

[ad_2]

solved How to call another classes super class? [closed]