Explore model answers categorized by subjects like Java, HTML, DBMS, and more.
Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns .
Method is that :
setBounds()
Basic diff are there :
> The >> operator : carries the sign bit when shifting right.
> The >>> operator : zero-fills bits that have been shifted out.
A non-local or inner class may be declared as public, protected, private, static, final, or abstract.
It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.
The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.
The Collections API is a set of classes and interfaces that support operations on collections of objects.
The List interface is bassically provides support for ordered collections of objects.
The Vector class is bassically a provides the capability to implement a growable array of objects.
The Iterator interface is bassically used to step through the elements of a Collection .
The EventObject class and the EventListener interface support event Handaling.
The GregorianCalendar is bassicallt provides support for traditional Western calendars
The Local class is bassically used to tailor program output to the conventions of a particular geographic, political, or cultural region .
The SimpleTimeZone class is bassically provides support for a Gregorian calendar
The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.
The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.
The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.
The Set interface is bassically a use for method which provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.
Hash table is very important that time When a program wants to store a key value pair, one can use Hashtable.
The existing object will be overwritten and thus it will be lost.
There are many diff :
> The size is the number of elements actually stored in the vector, While capacity is the maximum number of elements it can store at a given instance of time.
Yes, A Vector can contain heterogenous objects. Because a Vector stores everything in terms of Object.
Yes, A ArrayList can contain heterogenous objects. Because a ArrayList stores everything in terms of Object.
An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It is a construct which collection classes return when We request a collection of all the objects stored in the collection. It allows sequential access to all the elements stored in the collection.
The basic difference between a Vector and an ArrayList is that :
> Vector is synchronized while ArrayList is not. Thus whenever there is a possibility of multiple threads accessing the same instance, one should use Vector. While if not multiple threads are going to access the same instance then use ArrayList.
> Non synchronized data structure will give better performance than the synchronized one.
Basic diff are there :
> Map is Interface and Hashmap is class that implements this interface.
The Basic diff are there :
> Iterator : Enables we to cycle through a collection in the forward direction only, for obtaining or removing elements
> ListIterator : It extends Iterator, allow bidirectional traversal of list and the modification of elements.
The Basic diff are there :
> Iterator : Enables you to cycle through a collection in the forward direction only, for obtaining or removing elements
> ListIterator : It extends Iterator, allow bidirectional traversal of list and the modification of elements.
Basic diff are there :
> The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.
> HashMap allows null values as key and value whereas Hashtable doesn�t allow nulls.
> HashMap does not guarantee that the order of the map will remain constant over time.
> HashMap is non synchronized whereas Hashtable is synchronized.
> Iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn\'t.
Th Basic diff are :
> A Set stores elements in an unordered way and does not contain duplicate elements, whereas a list stores elements in an ordered way but may contain duplicate elements.
The Basic diff are there :
> Vector is synchronized whereas ArrayList is not.
> The Vector class provides the capability to implement a growable array of objects.
> ArrayList and Vector class both implement the List interface. Both classes are implemented using dynamically resizable arrays, providing fast random access and fast traversal.
> In vector the data is retrieved using the elementAt() method while in ArrayList, it is done using the get() method.
> ArrayList has no default size while vector has a default size of 10. when we want programs to run in multithreading environment then use concept of vector because it is synchronized. But ArrayList is not synchronized so, avoid use of it in a multithreading environment.
The Iterator is bassically an interface, Which is used to traverse through the elements of a Collection. It is not advisable to modify the collection itself while traversing an Iterator.
We have a many ways to access the elements of a collection which is followinf as :
> Every collection object has get(index) method to get the element of the object. This method will return Object.
> Collection provide Enumeration or Iterator object so that we can get the objects of a collection one by one.
The Set interface is bassically use for the methods which is provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.
There are many diff b/w stack and DS, But here basic diff are following as :
> Stack is a data structure that is based on last-in-first-out rule (LIFO), while queues are based on First-in-first-out (FIFO) rule.
The Map interface bassically used associate keys with values.
The Properties class is bassically a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used.
> Vector
> ArrayList
> LinkedList
> None of the above
ArrayList and Vector both use an array to store the elements of the list. When an element is inserted into the middle of the list the elements that follow the insertion point must be shifted to make room for the new element. The LinkedList is implemented using a doubly linked list; an insertion requires only the updating of the links at the point of insertion. Therefore, the LinkedList allows for fast insertions and deletions
This class implements the set interface, backed by a hash table ,Actually a HashMap instance. It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the Null element. This class offers constant time performance for the basic operations assuming the hash function disperses the elements properly among the buckets.
Diff are there :
> Enumeration : It is series of elements. It can be use to enumerate through the elements of a vector, keys or values of a hashtable. We can not remove elements from Enumeration.
> ArrayList : It is re-sizable array implementation. Belongs to \'List\' group in collection. It permits all elements, including null. It is not thread safe.
> Hashtable : It maps key to value. We can use non-null value for key or value. It is part of group Map in collection.
> Collections : It implements Polymorphic algorithms which operate on collections.
> Collection : It is the root interface in the collection hierarchy.
Many diff are there :
> An ArrayList is resizable, where as, an array is not.
> ArrayList is a part of the Collection Framework. We can store any type of objects, and we can deal with only objects. It is growable.
> Array is collection of similar data items. We can have array of primitives or objects. It is of fixed size. We can have multi dimensional arrays.
Array V/s ArrayList
> can store primitive > Stores object only
> fix size > Resizable
> can have multi
dimensional
> lang > Collection framework
Yes, We can limit the initial capacity. We can construct an empty vector with specified initial capacity.
public vector(int initialcapacity)
The methods to override are equals() and hashCode().
Basic diff are there :
> The Functionality of Enumeration interface is duplicated by the Iterator interface.
> Iterator has a remove() method while Enumeration doesn\'t.
> Enumeration acts as Read-only interface, because it has the methods only to traverse and fetch the objects, where as using Iterator we can manipulate the objects also like adding and removing the objects.
> Enumeration is used when ever we want to make Collection objects as Read-only.
Java Collections Framework is bassiclaly provides a well designed set of interfaces and classes that support operations on a collections of objects.
The Enumeration interface bassically allows us to iterate through all the elements of a collection. Iterating through an Enumeration is similar to iterating through an Iterator. However, there is no removal support with Enumeration.
Basic methods are there :
> boolean hasMoreElements();
> Object nextElement();
Basic diff are there :
> The Enumeration interface allows us to iterate through all the elements of a collection.
> Iterating through an Enumeration is similar to iterating through an Iterator. However, there is no removal support with Enumeration.
> HashSet and
> TreeSet
Are the two Set implementations available in the Collections Framework.
The Basic diff are there :
> HashSet Class implements java.util.Set interface to eliminate the duplicate entries and uses hashing for storage. Hashing is nothing but mapping between a key value and a data item, this provides efficient searching.
> The TreeSet Class implements java.util.Set interface provides an ordered set, eliminates duplicate entries and uses tree for storage.
> ArrayList and
> LinkedList
Are the two List implementations available in the Collections Framework.
The Basic diff are there :
> The ArrayList Class implements java.util.List interface and uses array for storage. An array storage\'s are generally faster but we cannot insert and delete entries in middle of the list.To achieve this kind of addition and deletion requires a new array constructed. We can access any element at randomly.
> The LinkedList Class implements java.util.List interface and uses linked list for storage.A linked list allow elements to be added, removed from the collection at any location in the container by ordering the elements.With this implementation we can only access the elements in sequentially.
LinkedList
A Map is bassically a special kind of set with no duplicates. The key values are used to lookup, or index the stored data. The Map interface is not an extension of Collection interface, it has it\'s own hierarchy. Map does not allow duplicates in the collection. In Map implementations null is valid entry, but allowed only once.
> HashMap and
> TreeMap
Are two types of Map implementations available in the Collections Framework.
The Basic diff are there :
> The HashMap Class : Its implements java.util.Map interface and uses hashing for storage. Indirectly Map uses Set functionality so, it does not permit duplicates.
> The TreeMap Class : Its implements java.util.Map interface and uses tree for storage. It provides the ordered map.
Once array size is already set, We cannot change size of the array. To deal with this kind of situations in Java uses Vector, it grows and shrink it\'s size automatically. Vector allows to store only objects not primitives. To store primitives, convert primitives in to objects using wrapper classes before adding them into Vector.The Vector reallocates and resizes itself automatically.
vt is bassically an instance of Vector class with an initial capacity of 3 and grows in increment of 10 in each relocation .
We need to wrap the primitive data type into one of the wrapper classes found in the java.lang package, like : > Integer, > Float, or > Double, as in: Integer in = new Integer(5);
Vector and ArrayList are bassically very similar. Both of them represent a growable array. The main difference is that Vector is synchronized while ArrayList is not.
We cannot directly make an array larger. We must make a new (larger) array and copy the original elements into it,usually with System.arraycopy(). If we find yourself frequently doing this, the Vector class does this automatically for us, as long as our arrays are not of primitive data types.
Because a synchronized HashMap requires an extra method call, a Hashtable is faster for synchronized access.
java.util .
System. arraycopy()
ArrayIndexOutofBoundsException
The GregorianCalendar class is bassically use for provides support for traditional Western calendars .
The SimpleTimeZone class is bassically use for provides support for a Gregorian calendar .
The ResourceBundle class is bassically 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.
The EventObject class and the EventListener interface support event processing.
The enableEvents() method is bassically 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.
When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.
A thread enters the waiting state when it blocks on I/O.
A Thread is in the ready state after it has been created and started.
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the threads run() method when the thread is initially executed.
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.
The wait(),notify(), and notifyAll() methods are bassically used to provide an efficient way for threads to wait for a shared resource. When a thread executes an objects wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the objects notify() or notifyAll() methods.
If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an objects lock, it enters the waiting state until the lock becomes available.
The operating systems task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
When a tasks interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.
An executing thread is in the running state.
A Thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an objects lock, or by invoking an objects wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.
All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.
A thread class may be declared as a subclass of Thread, or it may implement the Runnable interface.
One way is, before storing the cookie URLEncode it. URLEnocder.encoder(str); And use URLDecoder.decode(str) when you get the stored cookie.