To override a method from a parent class properly you must have matching return types. NO CLASS that is inheriting from another has to be inheriting from an abstract class meaning when we are overriding methods they have to match word for word like the toString method from parent class Object. Must always be
"public String toString(){
}"
For this question :
Johhny did the method overriding of mA() method in class B as shown below. What exactly did he do wrong?
public class A {
public double mA() {
// code
}
}
public class B extends A {
public int mA() {
// code
}
The method in class B needs to look like:
"public double mA(){
//code
}"
To properly override the parent method.