[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Technical Interview Questions and Answers :: Java

    11 / 66

    What is an Iterator ? How do you traverse through a collection using its Iterator?

    Iterator allows to traverse the collection and also it has methods which enables to obatin or remove elements. ListIterator adds the feature of traversing the list bi-directionally, also modify the elememts.

    Eg.: Iterator itr = al.iterator();

           while(itr.hasNext()) {}

    Please Login First :

    12 / 66

    What is the List interface?

    List is subinterface of collection interface 

    List is objects can be stored in sequencelly order 

    List objects can be stored in index or access by its index

    List is preserve the order of insertion.

    List duplicate objects can be stored and also null insertion is allowed.

    list is 3 implemention classes

    1.ArrayList Class

    2.LinkedList Class

    3.Vector Class

    Please Login First :

    13 / 66

    What are the advantages of ArrayList over arrays ?

    arrays store only primitive type values and arraylist store primitive type

    Please Login First :

    14 / 66

    What is the Set interface ?

    A set is a collection that cannot contain duplicate elements. Set has it's implementation in various classes like HastSet, TreeSet, LinkedHashSet. Set has only methods that are inherited from Collection and adds the restrictions to prohibit duplicate elements.

    Please Login First :

    15 / 66

    What is a Map ? About HashMap.

    Map contains values on the bais of keys.

    Keys= value key.

    These keys are known as entry.

    HasMap classes implements the Map interface by using Hash Table.

    Please Login First :

    16 / 66

    What is the Comparable and Comparator interface ?

    Java Comparable interface is used to order the objects of user-defined classes. It has compareTo(object) method and is available in jva.lang package.

    Java Comparator interface is available in java.util package. It has two methods compare(Object obj1, Object obj2) and equals(Object element).

    Please Login First :

    17 / 66

    What is immutable object? Can you write immutable object?

    An immutable object cannot be modified after it has been created. Also can be said unchangeabe object.

    Please Login First :

    18 / 66

    What is the difference between creating String as new() and literal?

    When 'new String()' is used, it creates a new string object in the heap memory and as when literal is used, it may return an existing object from the string pool, it exists else creates a new object.

    Please Login First :

    19 / 66

    What is difference between StringBuffer and StringBuilder in Java ?

    StringBuffer has same objects as StringBuilder, but each method in StringBuffer is synchronized,i.e., it's thread safe. That's why StringBuilder is faster than StringBuffer.

    Please Login First :

    Singleton class is a design pattern where it allowes creating only one object per class

    we should define constructor as private it object creation is restricted

    we should use static method this method is returen object of same class only

    Please Login First :