The easiest way to find out is to make up a test app.
public class MasterTest {
public static void main(String[] args) {
Master master = new Master();
A a = new A();
// exercise/test your classes...
}
}
class Master {
String name;
Master(String name) {
this.name = name;
}
public void rideTheHorse() {
System.out.println("riding the horse":
}
// other methods
// try methods that return something
public String toString() {
return name;
}
}
class A extends Master() {
// call methods and access fields of superclass
}
Can inheritance be private?
Possibly, depends on what you have in mind. We have the
private access modifier and the
final keyword available. Play with them in your test app.