Today's Jobs :


CORE JAVA FREQUENTLY ASKED QUESTIONS AND ANSWERS-8


CORE JAVA FREQUENTLY ASKED QUESTIONS AND ANSWERS-8

Question: How are Observer and Observable used?  
Answer:   Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

Question: Can a lock be acquired on a class?  
Answer:   Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.

Question: What state does a thread enter when it terminates its processing?  
Answer:   When a thread terminates its processing, it enters the dead state.

Question: How does Java handle integer overflows and underflows?  
Answer:   It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

Question: What is the difference between the >> and >>> operators?  
Answer:   The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.

Question: Is sizeof a keyword?  
Answer:   The sizeof operator is not a keyword.

Question: Does garbage collection guarantee that a program will not run out of memory?  
Answer:   Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection

Question: Can an object's finalize() method be invoked while it is reachable?  
Answer:   An object's finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object's finalize() method may be invoked by other objects.

Question: What value does readLine() return when it has reached the end of a file?  
Answer:   The readLine() method returns null when it has reached the end of a file.

Question: Can a for statement loop indefinitely?  
Answer:   Yes, a for statement can loop indefinitely. For example, consider the following: for(;;) ;

Question: To what value is a variable of the String type automatically initialized?  
Answer:   The default value of an String type is null.

Question: What is a task's priority and how is it used in scheduling?  
Answer:   A task's priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.

Question: What is the range of the short type?  
Answer:   The range of the short type is -(2^15) to 2^15 - 1.

Question: What is the purpose of garbage collection?  

Answer:   The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be reclaimed and reused.