1) What are checked and unchecked exceptions?
Ans: It is important to understand the meaning of checked which is checked by compiler. The compiler flashes an error when a method can throw a checked exception. The kind of exceptions falling under this category are the ones for which the developer has no control like file permissions and network outage.
Java
Unchecked exceptions are the exceptions which arise primarily because of some fault on the developer's side. This includes not initializing reference variables properly, accessing non existing index in an array etc. The developer is not notified about these kind of exceptions.
Checked exceptions are usually considered as disguise as one is forced to use catch or throws irrespective of the intention.
Core Java
2) What is serialVersionUID?
Ans: serialVersionUID refers to the version given to a particular class with respect to serialization operation.
Java Tutorial
serialVersionUID acts like meta data for serialization and de-serialization operations. The id if not added by developer is generated by JDK. The significance of serialVersionUID is that one can create various versions of class and hence allow/dis-allow the serialization/de-serialization of objects of this class.
3) How does Garbage Collection works?
Ans: Garbage collection is mechanism by which JVM automatically cleans up the memory occupied by objects. These are the objects which are no longer required by the application and there is no live reference pointing to these objects.
A Java program can’t force garbage collector to run but one can suggest the garbage collector to run by using the statement System.gc()
Core Java Tutorial
No comments:
Post a Comment