Saturday, 10 September 2011

What are the Applet’s Life Cycle methods? java interview questions..


Ans:
 Following are methods in the life cycle of an Applet:

init() method – called when an applet is first loaded. This method is called only once in the                              entire cycle of an applet. This method usually intialize the variables to be used in the applet.

start( ) method – called each time an applet is started.

paint() method – called when the applet is minimized or refreshed. This method isused for drawing different strings, figures, and images on the applet window.

stop( ) method – called when the browser moves off the applet’s page.

• destroy( ) method – called when the browser is finished with the applet.

How to Make a Class Serializable ? java interview questions


Ans:
There are four basic things you must do when you are making a class serializable. They are:
1. Implement the Serializable interface.
2. Make sure that instance-level, locally defined state is serialized properly.
3. Make sure that superclass state is serialized properly.
4. Override equals( ) and hashCode( ).

Define Hashtable,HashMap and HashSet ? java interview questions


Ans:
Hashtable


Hashtable is basically a datastructure to retain values of key-value pair.
  • It didn’t allow null for both key and value. You will get NullPointerException if you add null value.

  • It is synchronized. So it come with its cost. Only one thread can access in one time.
HashMap
Like Hashtable it also accepts key value pair.
  • It allows null for both key and value

  • It is un-synchronized. So come up with better performance.
HashSet
HashSet does not allow duplicate values. It provides add method rather put method. You also use its contain method to check whether the object is already available in HashSet. HashSet can be used  where you want to maintain a unique list.

diferents between awt and swing? java interview questions...

write your answers here?

what is class? java interview questions....

Ans:
  •  java class is a specification of how to construct something and also called template.
  •  Java classes contain multiple fields , variables and methods.
  • The structure of a class and its subclasses is called the class hierarchy.

syntax:

         class classname{

              //tour own code

         }

what is polymorphism? java interview questions....

Ans:

  •  ablity to make more then one form for same function.
  • ability to process objects differently depending on their data type or class    
  • the characteristic of being able to assign a different meaning or usage for same function.
  • it's used to code reusability.

There are two types of polymorphism,
  1.  overloading
  2.  overriding