Will the child class have access to the parent class's methods?
class Parent{
private String s;
public Parent(){
s = "hi";
}
public String getS(){
return s;
}
}
class Child extends Parent{
}
Will the child class have access to the parent class's methods?
class Parent{
private String s;
public Parent(){
s = "hi";
}
public String getS(){
return s;
}
}
class Child extends Parent{
}
Of course. The child can access all public, protected and package access methods and fields. This is not changed by the fact that the child is "empty". It does not even need an explicit constructor since the parent only has a parameterless one.
Its not mandatory to define a constructor in a child class because there will be a default constructor, but if you intend to change any properties of the Parent Class when instantiating Child Class, you may define a constructor and inside you can access and change the properties of parent class.
class Child extends Parent{
public Child() {
s = "hi hi hi"
}
}