>>PREVIOUS>>
17. KEYWORDS IN JAVA
/* class , method, constuctor, subclass , superclass, this, super, final, finalize(), garbage collection, method overriding, package, interface, import, extend, implement, private, public, protected, static , try, catch, finally, throw, throws , thread, multhread, run, suspend, resume, start, stop, synchronization, deadlock, applet. */
Bytecode
Java compiler generates machine independent bytecode instead of machine dependent exe file. So it gives ‘write once run anywhere’ . Due to this, most of the communication programs are done in Java instead of using C++ or VC++.
Class
The most important feature of the oop is classes. A class defines the shape and behaviour of an object and is a template for multiple object with similar features. Class contains the decl of instance variables and methods.
Constructor
A constructor initializes an object immediately upon creation. Once defined, it is automatically called immediately after the object is created before the new operator is completed. It has the same name as class and is similar to method but does not have the return type.
Garbage collection
When no references to an object exist, that object is assumed to be no longer needed, and the memory occupied by the object is reclaimed. This technique is called garbage collection.
finalize( )
This method is called just prior to garbage collection. It means it is called, when an object goes out of scope.
New
The new operator dynamically allocates memory for the object and returns reference to it.
This
this can be used inside any method to refere to the current Object.
Method overloading
It is possible to have two or more methods with same name but different parameters within the same class. This is called method overloading.
Method Overriding
Whenever there are methods of the same name both in the base class as well as in the derived class and if that method is called by main, the method in the derived class is always executed. This is called overriding.
Recursion
It is a process of defining something in terms of itself.
Static
When a member is declared as static, it can be accessed before any objects of its class are created and without reference to any object.
Final variable
used to declare constant variable . final float PI=3.14
Inheritance
Inheritance is the method of creating new class based on the already existing class. The new class derived is called as sub class or derived class which has all features of the existing class and its own. The existing class is called as super class or base class.
Adv : resuablity of code, accessibility of variables and methods of the base class
by the derived class.
If the class is derived from more than one class , then it is called as multiple inheritance. This is not available in Java.
Extend
extend keyword is used to create a subclass from a basic class.
Super
super has two forms. First it calls the superclass’s constructor. The second is used to access a member of the superclass that has been hidden by a member of a subclass.
Thread
A thread is a line of execution. Using multithreading, we can run the different parts of the program at a time.
Synchoronized.
This keyword is used with a method to enable synchronization. It contains an object which allows only one thread to
Network
A set of computers and peripherals physically connected together to enable sharing of resources and communication. Java network can be done either by Datagram which contains DatagramPacket for container of data and DatagramSocket which contains send and receive methods or TCP/IP which contains Socket class for client and Serversocket for server.
RMI
It allows an object running in a system to access a method that runs on another system. It is used to create distributed application in Java. In this rmic compiler is used to create Stub class and Skeleton classes for client and server respectively. Rmiregistry is used to map the name of server.
Beans
Beans are software component that are reusable in variety of environments. After creating beans, it can be added to toolbar of microsoft office, browser, etc.
Servlets
Servlets are small program that are executed on the web server to extend the functionality of the server. It contains two packages javax.servlet and javax.servlet.http
New in Java 2.0
Swing – contains tabbed panes, scroll panes, picture button, etc.
Collections
More security mechanisms
JIT – to create exe file instead of bytecode
Can play wav,au,midi and sudio files
Drag and drop capabilities
wait( ) , sleep( ) and suspend( ) are deprecated in Java 2.0
Java Plug-in directos browser to use JRE rather than JVM