Anda di halaman 1dari 1

Q2: Is null is a Keyword ?

Ans : There are three more reserved words in Java: true, false, and null. Technically,
they are literal values and not keywords. However, they cannot be used as
identifiers, and they have a specific meaning to the Java compiler.
Q: What is difference between ArrayList And Vector
Ans Vector are synchronized when Arraylist are not sychronized
Lists. Also known as a sequence, a list is a collection of ordered elements, and
each element is accessed by an index. Lists allow for multiple entries and
multiple null elements. An array is an example of a list, and other examples
include the Vector, ArrayList, and LinkedList classes (all Sin the java.util
package).
Vector as an array that (after it reaches its capacity) simply grows larger the
next time an element is added to it. The elements in a Vector are accessed by
using an index, just like array elements. The elements also must be of type
java.lang.Object, which means that the only elements that cannot appear in a
Vector are the eight primitive data types. A Vector has two attributes: a
capacity and a capacity increment.
EG: The following statement instantiates an empty Vector with an initial capacity
of 50 and a capacity increment of 10:
Vector employees = new Vector(50, 10);
Size and capacity are two entirely different attributes of a Vector. The size of a
Vector is the number of elements in the Vector. The capacity of a Vector is the
amount of room available for adding elements before the Vector needs to grow. For
example, the employees Vector is empty, so its size is 0. However, it has room for 50
objects, so its capacity is 50.
Q: What is difference between overloading and overriding ?
Ans:
Overloading Overriding
It occurs when two or more methods use the It occurs when a subclass method and a
same name (but different parameter list) superclass method use the same name( and
matching parameter list)
They have different type of return types They have matching return types
May they have different declared excep0tions They must have compatible declared exceptions
They do not block inheritance from superclass They block the inheritance from the super class

Anda mungkin juga menyukai