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 .