JAVA Programming
JAVA Programming
JAVA Programming
IS-A Relationship:
Implements:
The implements keyword is used by classes by inherit from interfaces. Interfaces can
never be extended.
d. Polymorphism
Polymorphism is a term that describes a situation where one name may refer to
different methods.
In java there are two types of polymorphism: overloading type and overriding type.
1. Overloading:
Overloading occurs when several methods have same names with different method
signatures. Overloading is determined at the compile time.
2. Overriding:
Overriding occurs when a class method has the same name and signature as a
method in parent class. Overriding is determined at the run time.
9. Interface:
An interface is a collection of abstract methods.
Similarities between Class and interface:
1. An interface can contain any number of methods.
2. An interface is written in a file with a .java extension, with the name of the interface
matching the name of the file.
3. The byte code of an interface appears in a .class file
4. Interfaces appear in packages, and their corresponding byte code file must be in a
directory structure that matches the package name
Data Structures:
There are many classes and Interfaces are very powerful and perform a wide range of functions
in java util package.
Enumeration:
Enumeration interface isn’t itself a data structure, but it is very important with the context of
other Data Structures. Enumeration interface retrieves successive element from a data
structure.
Enumeration interface defines the methods by which we can enumerate the elements in a
collection of objects.
Methods:
boolean hasMoreElements();
Object NextElement();
BitSet:
A bitset is a class creates a special type of array that holds bit values. This is similar to
vector class.
Vector:
A vector is a class similar to dynamic arrays. Vector is synchronized. Like an array,
elements of a Vector object can be accessed via an index into the vector.
The nice thing about using the Vector class is that you don't have to worry about setting it to a
specific size upon creation; it shrinks and grows automatically when necessary.
Stack:
Stack class implements Last-In-First-Out(LIFO) order stack of elements. It is subclass of
vector. Stack includes all the methods defined by Vector, and adds several of its own.
Methods:
Boolean empty(); tests stack is empty or not
Object peek(); returns top of the element
Object pop(); remove the element from the top
Object push(Object element); add element to top and returns same element
Int search(Object element); search stack element
Dictionary:
A dictionary is an abstract class which defines a data stricter for mapping keys to values.
Methods:
Enumeration elements(); returns an enumeration
Object get(Object key); returns object that contains a the value associated with key.
Boolean isEmpty(); returns true if the dictionary is empty.
Enumeration keys(); returns enumeration of keys from the dictionary
Object put(Object key, Object value); Insert key and value
Object remove(Object key);removes key and value
Int size(); returns size of dictionary
Hashtable:
Hashtable is also like Dictionary. It stores key and a value.
Properties:
Properties is a subclass of Hashtable. It is used to maintain lists of values in which the
key is a String and the value is also a String.
Multi Threading:
Java provides built-in support for multi threaded programming. Multi threaded program
contains two or more parts that can run concurrently, each part of such program is called a
thread and each thread defines a separate path of execution.
A multithreading is a specialized form of multitasking.
process: A process consists of the memory space allocated by the operating system that can
contain one or more threads.
REF:
1. http://www.tutorialspoint.com/java/index.htm
2. http://www.programmersheaven.com/2/FAQ-JAVA-What-Is-Polymorphism