Sunday, 1 April 2012

Important point of JAVA


1) overriden method doesn't throws IOException
2)If all variables =null , then its shows runtimeexception (NULLPOINTEREXCEPTION)

3) If catch(Exception e)
{}
catch(ArithmeticException e)
{}
 -> shows error bcos ArithmeticException that subclass of excetion.

4) catch(ArithmeticException e)
{}
catch(Exception e)
{}
  -> it allows

5)  ENUM related : Correct lines
class enum2
{
 public enum Direction {NORTH,WEST,EAST}
public class aa()
{
//enum2.Direction d=enum2 Dirction.NORTH;

   Direction d = Direction.NORTH;  It allows
}
}

6) Direction {NORTH,WEST,EAST}
   the expression (NORTH==NORTH) and NORTH.equals(NORTH) both are true

7)It is possible for more than two threads to deadlock at once.
If a piece of code is capable of deadlocking, you cannot eliminate the possibility of
deadlocking by inserting
invocations of Thread.yield().

9890040911 shridhar jahagirdar

8) sum ref. variables on stack and sum on heap.

9)  Treeset : provide array manipulation utilities
    Array :  provide collection manipulation utilities
    sorted set : defines base methods for all collection obj. , defines base methods for ordered set

    Iterator : linear access to collection and provide concrete implementation of order set
   
    Collection : base method for array obj. and random access.

10) list : by integer index
     map : objectKey
     queue : holding elements for prior processing
     set : contains no. of pair elements such as s1 and s2. e'g s1.equals(s2);

9)public void go(String y[], int i) {
    System.out.println(y[y.length-1]+"");
It allows


11)  is a ->  object used. class A { List<B> b; } or class A {A a ; B b;}
      has a -> extends

12) protected long blipvert(int x) { return 0; }
error in stmt.. bcos not converting from long to int.

13) The hashCode method for a given class can be used to test for object inequality, but
NOT object equality, for that class.The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

14) The finalize() method for a given object is called no more than once by the garbage
collector.

15) A. declare reset() using the synchronized keyword
    C. declare getCount() using the synchronized keyword
    E. declare increment() using the synchronized keyword

No comments:

Post a Comment