7
casting eksplisit dari super class ke subclass
public class Animal { public void eat() {} } public class Dog extends Animal { public void eat() {} public void main(String[] args) { Animal animal = new Animal(); Dog dog = (Dog) animal; } } Tugas Dog dog = (Dog) animal;tidak menghasilkan kesalahan kompilasi, tetapi pada saat runtime ia …