Tag: programming languages

Questions Related to programming languages

  1. Execute notify(thread1); from within synchronized code of mon.

  2. Execute mon.notify(thread1); from synchronized code of any object.

  3. Execute thread1.notify(); from synchronized code of any object.

  4. Execute thread1.notify(); from any code(synchronized or not) of any object.

  5. You cannot specify which thread will get notified.


Correct Option: E
  1. The program exits via a call to System.exit(0);

  2. Another thread is given a higher priority.

  3. A call to the thread's stop method.

  4. A call to the halt method of the Thread class.


Correct Option: D
  1. Execute notify(thread1); from within synchronized code of mon.

  2. Execute mon.notify(thread1); from synchronized code of any object.

  3. Execute thread1.notify(); from synchronized code of any object.

  4. Execute thread1.notify(); from any code(synchronized or not) of any object.

  5. You cannot specify which thread will get notified.


Correct Option: E
  1. The program exits via a call to System.exit(0);

  2. Another thread is given a higher priority.

  3. A call to the thread's stop method.

  4. A call to the halt method of the Thread class.


Correct Option: D
  1. Runtime Exception

  2. finally block will be executed

  3. finally block will not be executed

  4. Compilation error in else block


Correct Option: C