Getting error "The inherited method in Abs.show() cannot hide the public abstract method in iface" for the below written code.
package com.xprodev;
abstract class Abs {
void show(){
System.out.println("in show");
}
abstract public void print();
}
interface iface {
void show();
void print();
}
public class BasicAbs extends Abs implements iface {
public static void main(String[] args){
BasicAbs a = new BasicAbs();
a.show();
a.print();
}
@Override
public void print() {
System.out.println("in print");
}
}
I can resolve the error by making show in Abs as public. But I have few questions
- Why the language support for this usage?
- What can be achieved if this is allowed?
- on calling a.print() only implementation of print will be called . Is that make sense to call this implementation is of method in Abs class or iface interface. Can we know that?