What is the purpose of the wait(), notify(), and notifyAll() methods ?
Correct Answer
The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource When a thread executes an object's wait() method, it enters the waiting state It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods
Correct Answer: With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value This often leads to significant errors
Correct Answer: Pass By Reference means the passing the address itself rather than passing the value Passby Value means passing a copy of the value to be passed
5. What is the purpose of garbage collection in Java, and when is it used ?
Correct Answer: The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used
Correct Answer: Static member class is a class defined inside outer class with static modifier EX: Class A { //top level class or outer class static class B { //static member class } }
Correct Answer: Non-static member class is a class defined inside outer class with out static modifier EX: class A { // top level class or outer class class B { //non-static member class } }
Correct Answer: Local class is class defined inside method EX; class A { // top level class public static void main(string[] args) { class B { // local class } } }