I am trying to perform an example as told by some faculty but don't seem to understand how this code would work.
public class Child extends Base {
void show() {
System.out.println("Child");
}
void display(){
System.out.println("Display");
}
public static void main(String[] args) {
Base b=new Child();
b.show();
b.display();
}
}
class Base {
void show() {
System.out.println("Base");
}
}
These two classes are in the same file can anyone please tell what is going on here as i am not able to understand.
$ javac Child.java
Child.java:20: error: cannot find symbol
b.display();
^
symbol: method display()
location: variable b of type Base
1 error