Wednesday, September 5, 2012

Java Model paper 2


1. Collections.sort(List list)
       - elements in the List should impliments comparable interface

2. Collections.sort(list, Comparator)
       - Sorts the specified list according to the order induced by the specified comparator.

3. Collections.sort(list, Comparator.reverseOrder())
      -Comparator.reverseOrder() Returns a comparator that imposes the reverse of the
        natural ordering on a collection of objects that implement the Comparable interface.

4. Use == to compare two primitives, or to see if two reference refer to the same object.

5. Use the equals() method to see if two different objects are equal

6.  Animal myDog = new Dog();
         with polymorphism, the reference type and object can be different.
                 new Dog(); - is Object
                 myDog - is reference variable
                 Animal - is reference variable type

7.  Dog  myDog = new Dog();
            Tells the JVM to allocate a space for a reference variable

8.  With polymorphism, the reference type can be a super class of the actual object type.

9. Abstract class can't be instantiated.

10. call the static method using Class name ex- Math(88,86)

11. Overridden method allow java to support run-time polymorphisam. It allows a general class to specify methods that will be common to all of its derivatives, while allowing subclass to define the specific implementation of some or all of those methods.
Overridden methods are another way that java implements the "one interface, multiple methods" aspect of polymorphism.

12. private synchronized void makeWithdrawal(int amount)
        synchronized keyword to modify a method so that only one thread at a time can access it.

13.