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)
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 unlock () {
synchronized (lock) {
lock.notify ();
System.out.print ( "2");
}
}
public static void main (String s []) {
new Thread (new SomeClass () {
public void run () {
lock ();
}
}). Start ();
new Thread (new SomeClass () {
public void run () {
unlock ();
}
}). Start ();
}
}
(Java)
(Java)
try {
throw new ArithmeticException ();
System.out.print ( "2");
}
catch (ArithmeticException e) {
System.out.print ( "1");
}
finally {
System.out.print ( "0");
}
(Java)
(Java)
class Square {
int s (int a, int b) {
System.out.print (a * b);
return a * b;
}
void s (int r) {
System.out.print (3.14 * r * r);
}
}
public class MyClass {
public static void main (String args []) {
Square x = new Square ();
xs (3, 12);
xs (1);
}
}
(Java)
1 ...
2 class A {
3 int a, b;
4 void sum () {
5 System.out.print (a + b);
6}
7}
8 class B extends A {
9 int c, d;
10 B (int b1, int b2) {
11 super ();
12 c = b1;
13 d = b2;
14}
15 void sum () {
16 System.out.print (c + d);
17}
18}