Wednesday, March 30, 2016

Java Collection

Iterator collection over Iterator vs For-each

   Only Iterator can modify the collection
Iterator vs ListIterator

  • Iterator travel only forward. ListIterator both side
  • Iterator can use on List, Set, Queue but ListIterator only List


ArrayList vs Vector

  • Vector is synchronized and ArrayList not
  • Vector increase its size by doubling, ArrayList in 50%

ArrayList vs LinkList

  • ArrayList use a dynamic array, LinkList use doubly linked list
  • ArrayList Fast store and fetch data, LinkList efficient manipulation



ArryList read past
LinkList list item modify fast 

Set
HashSet Use has map (hashCode()) need to implement hashCode() and equals() //hashcode Ojbject.hash(,,)
TreeSet   Use tree Map ordered
EnumSet 

HashSet vs TreeSet
HashSet  - no order , TreeSet - ascending order

HashMap vs HashTable
  •  HashTable synchronized HashMap not
  • HashTable can't have null key or value but HashMap can 
Collection vs Collections
  • Collection is interface and provide normal functionality
  • Collections is a class to sort and synchronize collections

Fail-Fast vs Fail Safe Iteration 
Fail-Fast - throw concurrent exc - HashMap,Vector, ArrayList, HashSet
Fail-Safe - create a copy when iterator -CopyOnWriteArrayList,
ConcurrentHashMap

Sunday, February 28, 2016

SQL Interview Question

Type Of JOINS
INNER JOIN-simple join/default
    Returns all rows for which there is at least one match in both table

LEFT JOIN- left outer join
    Return all rows form left table and the match row form right table

RIGIT JOIN-right outer join
    Return all from right table and match row for left table

FULL JOIN
    Return all rows for which there is a match in either of tables. union of left and right join

CROSS JOIN


   

Interview Question

IOC vs ID?
IOC
Giving control to the container to get instance of object is called Inversion of Control., means instead of you are creating object using new operator, let the container do that for you.

DI
Way of injecting properties to an object is called Dependency injection.
    We have three types of Dependency injection
        1)  Constructor Injection
        2)  Setter/Getter Injection
        3)  Interface Injection - not support by spring