Код: Выделить всё
public abstract class Solid{
//code...//
public abstract double volume();
}
Код: Выделить всё
public class Sphere extends Solid{
//code...//
public double volume(){
//implementation//
}
}
Код: Выделить всё
public class SolidMain{
public static void main(String[] args){
Solid sol = new Sphere(//correct parameters...//);
System.out.println(sol.volume());
}
Подробнее здесь: https://stackoverflow.com/questions/232 ... s-abstract
Мобильная версия