Looking for Програмування мовою Java test answers and solutions? Browse our comprehensive collection of verified answers for Програмування мовою Java at moodle.chnu.edu.ua.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
class A {
...
}
class B extends A {
...
}
class C extends B {
...
}
public class MyClass {
public static void main (String args []) {
A x1 = new A ();
B x2 = new B ();
C x3 = new C ();
x1 = x3;
x2 = x3;
System.out.println (x1.getClass ());
}
}
1 class A {
2 private int a;
3}
4 class B extends A {
5 int b;
6 B () {
7 super ();
8 b = 0;
9 }
10 }
Виконання програми завершилося помилкою. Які зміни можуть бути внесені для виключення помилки?
(Java)
public class Vehicle {
public static void main (String [] args) {
Vehicle [] v = new Car [5];
...
}
public void setVehicles (Vehicle c []) {
c [0] = new Vehicle ();
}
public void setVehicles2 (Vehicle c []) {
if (c [0] instanceof Vehicle) {
c [0] = new Vehicle ();
}
}
public void setVehicles3 (Car c []) {
if (c [0] instanceof Car) {
c [0] = new Car ();
}
}
}
class Car extends Vehicle { }
(Java)
(Java)
(Java)
(Java)
(Java)