Thursday, 22 September 2011

What are the differences between ArrayList and LinkedList? java interview questions....

Answer: 
  • it's is a List implementation backed by a Java array, like Vector class
  •  If there are lots of growth periods, performance degrades as the old array needs to be copied into the new array.
  •  However, random access is very quick as it uses an array index to access.
  • LinkedList, the List implementation is backed by a doubly linked list data structure, allowing easy inserts/deletions anywhere in the structure, but really slow random accesses as the access must start at an end to get to the specific position.

for more answers click here



Monday, 19 September 2011

java interview questions ...


What is a static method? java interview questions..

Ans:
  • Static variables are always called by the class name.
  • Class variables or static variables are declared with the static keyword in a class. These are declared outside a class and stored in static memory.
  • The scope of the class variable is same an instance variable. 
  • A static variable is associated with the class as a whole rather than with specific instances of a class. Each object will share a common copy of the static variables .
  •  Class variables are mostly used for constants Its initial value is same as instance variable and gets a default value when its not initialized corresponding to the data type.

for more answers click here


Friday, 16 September 2011

What is the difference between instanceof and isInstance? java interview questions

Ans:



  •  instanceof is used to check to see if an object can be cast into a specified type          without throwing a cast class exception.

  •  isInstance() determines if the specified object is assignment-compatible with the object represented by this Class.         

  • This method is the dynamic equivalent of the Java language instanceof operator.   


  •  The method returns true if the specified Object argument is nonnull and can be cast to the reference type represented by this Class object without raising a ClassCastException. It returns false

  • In instanceof operator You can compare it to a named type only, and not to a Class object. 
  • isInstance remove this problem and call instanceof operator dynamically.




for more answers click here

Monday, 12 September 2011

Difference between Overloading and Overriding? java interview questions...


Ans
          
               1. In overloading,there is a relation ship between methods 
                   available in the same class where as in overridding,there 
                   is relationship between a super class method and subclass 
                   method.
               2. overloading doesn't block  inheritence from the 
                   superclass where as overridding blocks inheritence.

              3. in overloading,seperate methods share the same name 
                  where as in overridding,subclass methods replaces the 
                 superclass.

              4.overloading must have different method signatures where 
                 as overriding must have same signature.

                                 more answers click here

What are the differences between boolean & operator and & operator? java interview questions

Ans:


  • When an expression containing the & operator is evaluated, both operands are evaluated.

  • And the & operator is applied to the operand. When an expression containing && operator is evaluated, the first operand is evaluated.


  •  If the first operand returns a value of true then only the second operand is evaluated otherwise the second part will not get executed. && is also called short cut and.

         more questions and answers click here .





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

Wednesday, 31 August 2011

what is jdbc? java interview questions ...

write your answers here

differents between string and string buffer? java interview questions ...

write your answers here

what is array list? java interview questions ...

write your ans here

what is map interface? java interview questions ...

write your answers here

what is exception? java interview questions ...

write your answers here....

what is list? java interview questions ...

write your answers here

what is thread? java interview questions ...

soon the answer uptade......

Tuesday, 30 August 2011

whai is set interface? java interview questions ...

 Answer :

  • Java collections Set interface is part of java.util package.
  • A set is a public interface that extends the collection interface 
  • It holds unique values(set does not contain duplicate elements).

It has two useful concrete classes that implements sets

  1. java.util.HashSet
   2.  java.util.TreeSet
                
  • Set value can get by Iterator interface.

Example:

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class SetExample {

    public static void main(String[] args) {

        // Set example with implement TreeSet
        Set<String> s=new TreeSet<String>();

        s.add("b");
        s.add("a");
        s.add("b");

        Iterator it=s.iterator();

        while(it.hasNext())
        {
          String value=(String)it.next();

          System.out.println("Value :"+value);
        }
    }
}


Output

Set Value :a
Set Value :b

  set ignore the duplicate value.

Monday, 29 August 2011

what is an interface? java interview questions ...

Ans:

  • An interface is a named collection of method declarations and constant declarations. 
  • here we only declare the methods not a implementation. 
  • it's implemented by a class using implements keyword.

syntax:

        interface interface name{

           //declaration of methods and constants

         }

        class class name implements{

       

            //implementation codes

        }

what is inheritance? java interview questions ...

Ans:

  • Java Inheritance defines an is-a relationship between a superclass and its subclasses.
  • The child class can use the methods and variables of the superclass and add to them its own methods and variables .
  • The keyword extends is used by the sub class to inherit the features of super class .
  •   Using inheritance we can achieve the concepts of reusability.

syntax:

             class A{

              //class A codes

            }

             class B{

             //class B codes and also use class A members

             }

what is encapsulation? java interview questions ...

Ans:
  • java encapsulation is  wrapping up of the data into single unit.
  • The process of hiding all the details of an object that do not contribute to its essential characteristics
  • for example if we declare the members(variable or method) public then we access the members into anywhere, but if we declare the private then we cant access the members out of class this is called encapsulation.

what is abstraction? java interview questions ...

Ans:
  • Java  Abstraction means to show only the necessary details to the client of the object .
  • without knowing the background of details we use. 
  • it is usually accomplished through the use of base classes with virtual functions , each derived function provides the details that implement the behavior behind that abstraction


what is an object? java interview questions ...

Ans:
  • Object is a run time entity.
  •  A set of data combined with methods for manipulating
        that data.

Three properties characterize objects:
  1. Identity
  2. State
  3. Behavior

Syntax:

     ClassName object ;

                  (or)

     ClassName object = new ClassName;

what is java? (or) define java? java interview questions ...

Ans:
  • java is a high level programming language developed by James Gosling for Sun  Microsystems.
  • java was originally called OAK ,later the name changed.
  • java is a neutral platform language(support all platform).
  • java is a Object Oriented Programming language.
  • java mainly developed by mobile device and internet.


Advantages:
  • Easy to Use
  • Reliability
  • Secure
  • Platform Independent  

java interview questions

  • What is the difference between procedural and object-oriented programs?
  • what is java? or define java?
  • What is the difference between Assignment and Initialization?
  • What is an Iterator?
  • What is casting?
  • what is static method?
  • What is final, finalize() and finally?
  • what is final?
  • How many ways can an argument be passed to a subroutine and explain them?
  • what id the meaning of final in variable , method and class?
  •  
  • What is OOPs?What is an Object and how do you allocate memory to it?
  • What is the difference between constructor and method?
  • what is class?
  • What is the difference between this() and super()?
  • What is the difference between an argument and a parameter?
  • What is an abstract class?
  • what is encapsulation?
  • What is daemon thread and which method is used to create the daemon thread?
    • What is meant by pass by reference and pass by value in Java?
    • What is the difference between an Interface and an Abstract class?
    • What are wrapper classes?
      • what is polymorphism?
      • Explain the usage of Java packages.
      • What is difference between overloading and overriding?
      • What is the purpose of garbage collection in Java, and when is it used?
      • what is thread?
      • what is inheritance?
      • What is the difference between superclass and subclass?
      • what is interface?
      • What is JDBC?
      • What is the difference between JDBC and ODBC?
      • What are drivers available?
      • what is swing?
      • what is diff between swing and awt?
      • What are the types of statements in JDBC?
      • What are the steps involved for making a connection with a database or how do you connect to a database?