Sunday, March 14, 2010

GATE 2010 RESULT  

0 comments

Monday, March 8, 2010

local inner class method  

0 comments

  • Sometimes we can declare a class inside a method such type of classes are called method local

inner classes

  • The main purpose of method local inner classes is to define method specific functionality

      The scope of method local inner classes is the scope of the method where it is declared.

    • This is the mostly rarely used type of inner classes.

    Example

    class Test{

    public void m1(){

    class Inner {

    public void sum(int I,int j){

    System.out.println(i+J);

    }//sum

    }//inner

    Inner i=new Inner();

    i.sum(10,20);

    //more code here

    I.sum(100,303);

    //more code here

    i.sum(102,84);

    }//m1()

    Public static void main(){

    New Test().m1();

    }

    }

    what is inner class & when we should go for inner classes  

    0 comments

    Some times we can declare a class inside another class such type of classes are called inner classes

    Example

    Class Car{

    //more code here

    Class Engine{

    //more code here

    }

    }

    Without existing Car object there is no chance of existing Engine object, hence Engine class has declared inside Car class.

    What are differences between arrays and collections?  

    0 comments

    Arrays

    Collections

    1. Arrays r fixed in size and hence once we created an array we are not allowed to increase or decrease the size based on our requirement.

    1. Collections are growable in nature and hence based on our requirement we can increase or decrease the size.

    2. Memory point of view arrays are not recommended to use

    2. Memory point of view collections are recommended to use.

    3. Performance point of view arrays are recommended to use

    3. Performance point of view collections are not recommended to use.

    4. Arrays can hold only homogeneous elements

    4. Collections can hold both homogeneous and heterogeneous elements.

    5. Arrays can hold both primitives as well as objects

    5. Collections can hold only objects.

    6. For any requirement, there is no ready method support compulsory programmer has to code explicitly.

    6. For every requirement ready made method support is available. Being a programmer we have to know how to use those methods and we are not responsible to implement those.


    Extension Factory Builder