Java Interview Questions - Page 12

Question: What is Serialization and deserialization? Answer: Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

Java Interview Questions - Page 12

Java Interview Questions - Page 12

     

Question: What is Serialization and deserialization? 
Answer:
Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

Question: what is tunnelling?
Answer:
Tunnelling is a route to somewhere. For example, RMI tunnelling is a way to make RMI application get through firewall. In CS world, tunnelling means a way to transfer data.

Question: Does the code in finally block get executed if there is an exception and a return statement in a catch block?
Answer:
  If an exception occurs and there is a return statement in catch block, the finally block is still executed. The finally block will not be executed when the System.exit(1) statement is executed earlier or the system shut down earlier or the memory is used up earlier before the thread goes to finally block.

Question: How you restrict a user to cut and paste from the html page?
Answer:
Using javaScript to lock keyboard keys. It is one of solutions.

Question:  Is Java a super set of JavaScript?
Answer:
No. They are completely different. Some syntax may be similar.

Question: What is a Container in a GUI?
Answer:
A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.

Question:  How the object oriented approach helps us keep complexity of software development under control?
Answer:
 

We can discuss such issue from the following aspects:

o Objects allow procedures to be encapsulated with their data to reduce potential interference.

o Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places.

o The well-defined separations of interface and implementation allows constraints to be imposed on inheriting classes while still allowing the flexibility of overriding and overloading.

Question: What is polymorphism?
Answer:
Polymorphism allows methods to be written that needn't be concerned about the specifics of the objects they will be applied to. That is, the method can be specified at a higher level of abstraction and can be counted on to work even on objects of yet unconceived classes.

Question: What is design by contract?
Answer:
The design by contract specifies the obligations of a method to any other methods that may use its services and also theirs to it. For example, the preconditions specify what the method required to be true when the method is called. Hence making sure that preconditions are. Similarly, postconditions specify what must be true when the method is finished, thus the called method has the responsibility of satisfying the post conditions.

In Java, the exception handling facilities support the use of design by contract, especially in the case of checked exceptions. The assert keyword can be used to make such contracts.

Question: What are use cases?
Answer:
A use case describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance. It is part of the analysis of a program. The collection of use cases should, ideally, anticipate all the standard circumstances and many of the extraordinary circumstances possible so that the program will be robust.

Question: What is the difference between interface and abstract class?
Answer:
 

o interface contains methods that must be abstract; abstract class may contain concrete methods.

o interface contains variables that must be static and final; abstract class may contain non-final and final variables.

o members in an interface are public by default, abstract class may contain non-public members.

o interface is used to "implements"; whereas abstract class is used to "extends".

o interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance.

o interface can "extends" another interface, abstract class can "extends" another class and "implements" multiple interfaces.

o interface is absolutely abstract; abstract class can be invoked if a main() exists.

o interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces.

o If given a choice, use interface instead of abstract class.