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!
(Java)
наступних полів потрібно оголосити статичними?
(Java)
(Java)
1 int i = 0;
2 while (i <3) {
3 System.out.print (i);
4 if (i> 1)
5 try {
6 throw new ArithmeticException ( "ex");
7 }
8 finally {
9 System.out.print (i);
10 }
11 catch (ArithmeticException e) {
12 System.out.print (i);
13 break;
14 }
15 i ++;
16 }
abstract class Shape {
double square;
abstract public void setSquare (double s);
}
Які нижчеперелічені фрагменти коду допустимі?
int a = 12;
int i = 4;
try {
while (i> 0) {
System.out.print (a / i);
i--;
}
}
finally {
System.out.print (i);
}
в порівнянні з класом Thread ?
(Java)
public abstract class SomeClass implements Runnable {
private Object lock = new Object ();
public void lock () {
synchronized (lock) {
try {
lock.wait ();
System.out.print ( "1");
} Catch (InterruptedException e) { }
}
}
public void notifyThread () {
synchronized (lock) {
lock.notify ();
}
}
public void unlock () {
synchronized (lock) {
lock.notify ();
System.out.print ( "2");
}
}
public static void main (String s []) {
SomeClass c = new SomeClass () {
public void run () {
lock ();
}
};
SomeClass c1 = new SomeClass () {
public void run () {
unlock ();
}
};
new Thread (c) .start ();
new Thread (c1) .start ();
c.notifyThread ();
}
}
(Java)
1 class A {
2 int a;
3 int b;
4 }
5 class B extends A {
6 int b;
7 ...
8 }
Яким кодом необхідно доповнити рядок 7, щоб в класі B змінна b класу А встановлювалася рівною 1?