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)
int b [] = new int [5];
for (int i = 0; i < = b.length (); i ++) {
b [i] = Math.sqrt (i);
}
(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);
}
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)
в порівнянні з класом Thread ?
(Java)
if (i == 0)
throw new ClassCastException ( "first");
if (i == 2)
throw new ClassNotFoundException ( "second");