logo

Crowdly

Browser

Add to Chrome

Програмування мовою Java

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!

Який метод згенерує помилку ArrayStoreException при передачі в нього масиву v ?

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)

View this question
Які твердження щодо ініціалізаторів класу вірні?

(Java)

50%
View this question
Які твердження щодо об'єкта класу File вірні?

(Java)

0%
0%
0%
0%
View this question

У програмі описаний клас:

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);

View this question
Яка операція зі посилальними змінними в тілі методу main() не приведе до помилки компіляції?

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 ();

...

}

}

0%
0%
0%
0%
0%
View this question
У програмі визначено клас Shapeі його спадкоємець клас Circle:

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 }

Виконання програми завершилося помилкою. Які зміни необхідно включити в текст програми, щоб виключити помилку?

View this question
Що потрібно підставити замість знаків підкреслення, щоб програма вивела на екран "12" :

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)

0%
0%
0%
0%
0%
View this question
Що буде виведено на екран в результаті виконання наступного фрагмента програми?

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 ++;

}

View this question
Що буде виведено на екран в результаті виконання наступного коду:

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)

View this question
Вкажіть варіанти коду, які не викличуть помилки компіляції.

(Java)

View this question

Want instant access to all verified answers on moodle.chnu.edu.ua?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome