Tuesday, October 9, 2007

Java Important Questions and concepts

Ques : Difference between Protected and default access?
Ans :
You cannot declare a class protected.
A class or a class member with default access (that is, no access modifier specified) can be accessed by any class in the same package as the class in question. Unlike a protected member, a member with default access cannot be accessed bya subclass that is in a different package from that of the class that contains the member. So, the default modifier provides less accessibility than the protected modifier

IMP: Java doesn't provide unsigned datatype and unsigned is not a keyword in java.
You use the signed types that are larger than the original unsigned type

The Interrupt Status Flag

The interrupt mechanism is implemented using an internal flag known as the interrupt status. Invoking Thread.interrupt sets this flag. When a thread checks for an interrupt by invoking the static method Thread.interrupted, interrupt status is cleared. The non-static Thread.isInterrupted, which is used by one thread to query the interrupt status of another, does not change the interrupt status flag.

By convention, any method that exits by throwing an InterruptedException clears interrupt status when it does so. However, it's always possible that interrupt status will immediately be set again, by another thread invoking interrupt.

No comments: