Answered Questions

  • Garbage Collector

    How does garbage collector decide which objects are to be removed? Can garbage collector be forced?

    KhyatiK

    • Nov 12th, 2010

    Garbage collector removes those objects from heap memory which are no longer referred by any other objects.Using System.gc() you can call garbage collector but its not neccesary that it will run.JVM decides when the Garbage Collector will run.

  • Exception Handling

    What is the output of the following program, When tested under JDK 5.0class ExceptionDemo{ public static void main(String[] args) { int a[] = new int[] {1,2,3,4,5}; try{ System.out.prinltln(a[6]); } catch(Exception e) { System.out.println("Catching Exception ..."); } catch(ArrayIndexOutofBoundsException ae) { System.out.println("Catching ArrayIndexOutOfBounds...

    kuchipudi Prasad

    • May 31st, 2012

    Output is "catching exception"