✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
public class Vehicle {
public static void main (String [] args) {
Vehicle [] v = new Car [] {new Car () };
...
}
public void setVehicles (Vehicle c []) {
c [0] = new Vehicle ();
}
public void setVehicles2 (Vehicle c []) {
if (c [0] instanceof Vehicle) {
c [0] = new Car ();
}
}
public void setVehicles3 (Vehicle c []) {
if (c [0] instanceof Car) {
c [0] = new Vehicle ();
}
}
}
class Car extends Vehicle { }
(Java)