[Tech.][Struts.][Servlet.][JSP.][EJB.][JNDI-JMS][SQL.][JDBC.]
CORE-JAVA: [OOP][CLASS][ABSTRACT][EXCEPTIONS][THREADS][UTILS][PACKAGES][JVM][CASTING][NETWORKING][RMI-XML]
What is the Collections API? (collections framework)
Java.util Collections API is a set of CLASSES and INTERFACES that support operations on collections of objects. They provide useful DATA STRUCTURES and ALGORITHMS. Some of the Classes are: Vector, Hashtable, and Arrays. It provides methods that perform useful computations, such as searching and sorting, on objects that implement collection interfaces. Collections are used to store, retrieve, manipulate, and communicate aggregate data. (Java.UTIL)
What is the List interface? (Java.util.List Interface)
Java.util.List interface provides support for ORDERED collections of objects. Also called as SEQUENCE collection. Lists may contain duplicate elements. Elements are based on their numerical position in the list (integer index). Some of the classes which Implement List Interface are: ArrayList, LinkedList, Vector, AbstractList, etc. (Tutor) (Linked List) (Framework)
(Ex:) public interface List extends Collection {
// Positional access:
Element get(int index); - Returns the element at the specified position in this list. Element set(int index, E element); - Replaces the element at the specified position. boolean add(E element); - Appends the element to the end. void add(int index, E element); - Inserts the specified element. Element remove(int index); - Removes the element at index. boolean addAll(int index, Collection c); - Inserts all of the collection elements.
// Search:
int indexOf(Object o); - Returns the index of the first occurrence else returns -1. int lastIndexOf(Object o); - Returns the index of the last occurrence.
// Iteration:
ListIterator listIterator(); - Returns a list iterator of the elements. ListIterator listIterator(int index); - starting at the specified position.
// Range-view:
List subList(int from, int to); - Returns a view of the portion. }
* What is an Iterator? (corejava)
A: An Iterator is a object or routine for accessing items from a list, array or stream, one at a time. It is used to step through the elements of a Collection. Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. It has three methods:
--boolean hasNext() //Returns true if the iteration has more elements.
--Element next() //Returns the next element in the iteration.
--void remove() //Removes from the underlying collection the last element returned by the iterator (optional operation). This interface allows us to walk a collection of objects, operating on each object in turn. Iterators allow the caller to remove elements from the underlying collection during the iteration. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator. Ex:
public static void main( String aArguments ) {
List<.string> flavours = new ArrayList<.string>();
Iterator<.string> flavoursIter = flavours.iterator();
while ( flavoursIter.hasNext() ){
System.out.println( flavoursIter.next() );
What is HashMap and Map? (Util)
A: Map is Interface and Hashmap is class that implements that.
A Map is an object that maps KEYS to VALUES. A map cannot contain duplicate keys. Each key can map to at most one value. The Map interface replaces the JDK 1.1 Dictionary class and is used to associate keys with values.
Both key and value are objects. Methods: containsKey(Object key) and containsValue(Object value)
Ex: Map m = new HashMap(); // Create a Map object.
Difference between HashMap and HashTable? (Util)
A: The HashMap class is roughly equivalent to HashTable, except that it is unsynchronized and permits nulls. (HashMap allows null values and null key where as HashTable doesn't allow).
HashMap does not guarantee that the order of the map will remain constant over time.
HashTable is synchronized and HashMap is not.
Difference between Vector and ArrayList? (Util)
A: Vector is synchronized and thus thread safe, whereas ArrayList is not. Thus Vector is slower but safer. When inserting an element into an ArrayList or a Vector, these objects will need to expand their internal arrays (if they run out of room). (Ex:) Vector vector = new Vector(); ArrayList array = new ArrayList(); vector.add(int , element); (String)vector.get(i); etc.
A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.
However Vector does possess a slight advantage since it can set the increment value. The Vector class provides the capability to implement a growable array of OBJECTS. (Tutor)
Which java.util classes and interfaces support event handling?
The EventObject class and the EventListener interface support event processing.
What is the highest-level event class of the event-delegation model?
The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.
What is the GregorianCalendar class?
The java.util.GregorianCalendar provides support for traditional Western calendars used by most of the world.
What is the Locale class?
The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.
Locale(String language, String country, String variant) - Constructor.
The language argument is a valid ISO Language Code. The country argument is a valid ISO Country Code. The variant argument is a vendor or browser-specific code. For example, use WIN for Windows, MAC for Macintosh.
What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar.
What is the Collection interface?
The java.util.Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.
What is the Set interface?
The java.util.Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.
What is the purpose of the enableEvents() method? (awt)
The java.awt.Component.enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.
What is the ResourceBundle class?
The java.util.ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program's appearance to the particular locale in which it is being run.
* [Read:Relationships-and-Happiness!][God-gave-us-everything.][Steps-Involved-In-Relationships.][Life-is-full-of-Tests.][Some-of-the-aspects-which-materialize-the-relationships.]
Winning Publications.
No comments:
Post a Comment