Posts

Showing posts from April, 2013

Java Interview Points

Java Interview Points Uses of finalizer :-  It acts as a safety net. It may be better to free the resources than never e.g. FileInputStream, Connection etc.  Object with native peers, the garbage collector doesn't know about it when it reclaimed the java peer. If native peer hold some critical resources, we can use this method to free the resources.  Clone will not work if the array fields are final because clone would be prohibited from assigning a new value to the field.  A method in an interface can’t be native, synchronized, strictfp but in the implementation class it can be since these keywords describe implementation properties rather than interface properties. Same is true for final.  Only data associated with specific instances of a class is serialized, because static data is associated with a class as opposite to an instance, so it’s not serialized automatically. To serialize static data, one must provide class specific serialization.  Array implementation in Ja

Why we have Runtime Exceptioons in Java

Image
Oracle  defines Exception as  "An  exception  is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions." We have three categories of exception as:- Checked Exceptions , which are subject to catch . All exceptions are checked exceptions, except for those indicated by  Error ,  RuntimeException , and their subclasses Runtime Exceptions are internal to the application and system does not expect to recover from. NullPointerException is type of RunTime Exception Error are exceptions which are external to applications like OutOfMemory Exception, StackOverFlow Exception.    The class diagram of Exception is as follows:- This discussion is regarding why we have Runtime type of exceptions in Java. When exception was first designed, there was worry about conditions that occur because of problems with the machine on which the program being run bugs in VM  security violations. These sort of thin