Which of the following methods is not a member of the Object class?
- wait()
- notify()
- notifyAll()
- join()
Answer:join()
join() is a non-static method defined within the class java.lang.Thread.
2)
class A extends Thread {
public void run() {
try {sleep(10000);} catch (InterruptedException ie){}}
public static void main(String[] args) {
A a1 = new A();
long startTime = System.currentTimeMillis();
a1.start();
System.out.print(System.currentTimeMillis() - startTime);
}}
What are the possible results of attempting to compile and run the program?
- Prints a number greater than or equal to 0
- The number printed must always be greater than 10000
- Compile-time error
- Run-time error