02-01-2013, 04:23 PM
JAVA
JAVA.doc (Size: 1.72 MB / Downloads: 27)
Introduction to JAVA
Created by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, Mike Sheridan in 1991.
It took 18 months to develop first working version.
Initially named as Oak, renamed as JAVA in 1995.
What led to creation of JAVA – Need of Platform Independent Language.
Second force – WWW (being developed at the same time).
Java derives its content from C, C++ as Java Designers knew that using familiar syntax would make Java appealing to legions of C,C++.
Why JAVA is better?
Architecture Independent.
Prior to Java, cyberspace was effectively closed to half the entities that now live there.
OOP based language, relation to the real world.
Built in API’s.
More Secured.
Available for all the platforms and devices like : Desktops, Web, Micro Devices etc.
Uses threads(multi tasking) to execute the programs.
Lighter Language as compared to others.
Iteration Statements
Java’s iteration statements are for, while, and do-while. These statements create what we commonly call loops. As you probably know, a loop repeatedly executes the same set of instructions until a termination condition is met. As you will see, Java has a loop to fit any programming need.
Packages:
Java provides a mechanism for partitioning the class name space into more manageable chunks. This mechanism is the package.
A Package is a collection of classes.
The package is both a naming and a visibility control mechanism.
You can define classes inside a package that are not accessible by code outside that package.
You can also define class members that are only exposed to other members of the same package
Exception Handling
There are two types of errors :
• Compile Time
• Run time
Compile Time errors are the syntax errors that are recognized by the compiler at compile time.
Run Time errors are the ones that occur when a program is running.
Run Time error might cause a program to crash or might not give the desired output, sometimes.
This is known as Exception, and the way to handle these exceptions is known as Exception Handling.
When an exceptional condition arises, an object representing that exception is created and thrown in the method that caused the error. That method may choose to handle the exception itself, or pass it on. Either way, at some point, the exception is caught and processed.
Java provides us with try{ } and catch(Exception e){ } block to overcome the exceptions/run time errors in our program.
There can be multiple catch blocks for single try block.
Exception is the base class for all the built in Exceptions and also for the user defined Exceptions.
There can be nested try catch blocks.
Applets
Applets are small applications that are accessed on an Internet server, transported over the Internet, automatically installed, and run as part of a web document.
All applets are subclasses (either directly or indirectly) of Applet. Applets are not stand-alone programs. Instead, they run within either a web browser or an applet viewer.
Applet extends the AWT class Panel. In turn, Panel extends Container, which extends Component.
These classes provide support for Java’s window-based, graphical interface.
As discussed earlier Applets can be used in Web Pages