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!
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 Car) {
c [0] = new Vehicle ();
}
}
public void setVehicles3 (Vehicle c []) {
if (c [0] instanceof Vehicle) {
c [0] = new Car ();
}
}
}
class Car extends Vehicle { }
(Java)
(Java)
(Java)
У програмі описаний клас:
class A { public int x = 0; public int y = 0; }
Що буде виведено на екран в результаті виконання наступного фрагмента програми?
A x; x = new A ();
System.out.print (x.y);
System.out.println (x.x);
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 ();
...
}
}
1 class Shape {
2 double square;
3 Shape (double r) {
4 square = 3.14 * r * r;
5 }
6 }
7 class Circle extends Shape {
8 double r;
9 Circle (double rad) {
10 r = rad;
11 super (rad);
12 }
13 }
Виконання програми завершилося помилкою. Які зміни необхідно включити в текст програми, щоб виключити помилку?
public class SomeClass {
public void perform () {
System.out.print ( "1");
}
public static void main (String [] args) {
SomeClass c = new SomeClass2 ();
c.perform ();
}
}
class SomeClass2 extends SomeClass {
public void perform () {
____
System.out.print ( "2");
}
}
(Java)
int a = 8, i = -1;
while (i <2) {
try {
System.out.print (36 / a);
}
catch (ArithmeticException e) {
System.out.print (36/2);
}
finally {
System.out.print ( "1");
}
a - = 3;
i ++;
}
public class SomeClass {
public static void main (String [] args) {
int a [] [] = { {1, 2 }, {3 } };
int b [] [] = (int [] []) a.clone ();
a [0] = new int [] {0 };
System.out.println (b [0] [0]);
}
}
(Java)
(Java)