JAVA
Java Operating System a general purpose OOPL developed by
Sunmicro System(USA) in the year 1991.
Originally it was named as OAK & it was renamed in 1995 as
JAVA.
JAVA can be used to develop two types of programs , these are
Application and Applets.
When we create applications, java is not much different from
other languages. But in case of an applet, it can be dynamically
downloaded across the network, which can react to user input.
To execute an application in java, the following two methods can
be adopted :
* Compiling the source code into the BYTE CODE using the java
compiler, i.e. javac
* Executing the byte code, using the JAVA interpreter, i.e. java
Byte code
The Source code is compiled by the java compiler. The
output of the compiler is not an executable code.
Rather it is an intermediate code called as the BYTE
CODE.
The byte code is stored in a file having extension
“.class”
After byte code is generated by the compiler, it is
interpreted by the JAVA interpreter to produce the
programming result.
JAVA Features
Some of the important features are described below
SIMPLE: java is simple because of the availability of
Object Oriented features in it.
SECURED: When an executable program is
downloaded, the risk of viral infection is severe, which
may infect the system with a virus.
PORTABILITY: Many type of computer with different
OS are available almost all computer are connected to
the internet now a days. Therefore, the code must be
sufficiently portable enough so that it can be
dynamically downloaded to the various platforms.
JAVA Features
OBJECT ORIENTED: java is a pure object oriented
programming language. The principle is “everything is
an object” is implemented in java.
ROBUST: java is robust, because it is a strictly typed
language. Due to this, the java compiler checks the
code at compile time to allow the programmer correct
the syntactical errors. It also handles the memory
management mistakes and exceptional condition.
MULTI-THREADED: java supports multi-threaded
programming. Which allow the programmer to write
programs, that may do many things simultaneously.
JAVA Features
Though it is a Object oriented Programming Language is
supports the following features
o DATA ABSTRACTION : Abstraction refers to the act of
representing essential features without including the
background the explanation details.
o ENCAPSULATION : the wrapping up of data &
function/methods into a single unit is known as
encapsulation
o MODULARITY : Modularity is the property of system that
has been decomposed into a set of cohesive & loosely
coupled modules. So the act of partitioning program into
individual is called modularity.
JAVA Features
o INHERITANCE : It is the capacity of one class of
things to inherit from another class.
o POLYMORPHISM : It is a ability for a data to be
processed in more than one forms. It is a property by
which the same message can be sent to object of
several different classes.
JVM
Java Virtual Machine
The java run time system is other wise known as the
JVM.
Execution of every java program is under the control of
JVM.
As the source code in JAVA is translated into the byte
code , it becomes easier to run the byte code in a wide
verity of environments.
Only requirement is the availability of JVM within
than environment.
Command Line Argument
An argument which is supplied/passed to the main()
from the command line at the time of calling the
main() by the java interpreters is called COMMAND
LINE ARGUMENT.
The arguments supplied from the command line are of
string type arguments. Therefore these arguments are
stored in the parameter of main() which is an array of
string objects i.e. args[]
Method Overloading
A class can contain two or more methods with same
name but different set of parameters. In this case the
methods are said to be overloaded & the process is
called method overloading.
In method overloading, methods may or may not have
same return type.
Constructor &
Constructor Overloading
A constructor is a specialize method/member function
of class
A constructor has the same name as the class in which
it is declared.
A constructor is syntactically similar to a method with
only exception that it has no return type not even void.
Once defined in a class, the constructor is
automatically called immediately after the object is
created.
Constructor &
Constructor Overloading
Like method overloading, constructor can also be over
loaded.
Constructor overloading is the process by which two
or more constructor defined in a class with different
list of parameters.
When overloaded constructor are called, java compiler
calls that constructor whose list of parameter exactly
matches with the values received from the calling
program.
Inheritance
The mechanism of deriving a new class from an
existing class is called inheritance.
The class from which the new class is derived is called
SUPER CLASS and the class which is derived is called
SUB CLASS
Inheritance allows
-> The creation of hierarchical classification
->Code reusability
Method Overriding
When a method in a subclass is exactly same as in
method in a super class, then method overriding takes
place.
In method overriding, the subclass and super class
method have same name, same return type and same
parameter list.
Due to inheritance, the subclass method overrides the
super class method. Therefore when an overridden
method is called from within a subclass, it always
refers to the method define in the sub class
Interface
Since java does not support multiple inheritance, it
provides an alternate approach to multiple inheritance
and that approach is Interface.
An interface, is a kind of class that lacks instance
variable and its methods are declared without only
body.
Therefore using an interface, it is specified that what a
class must do but not how it does it.
Variable declared with in a interface must have FINAL
declaration
Interface
Syntax of declaration of variables
static final <type of variable> <variable name>=<value>
E.g. : static final int a=5;
Syntax of declaration of methods
<return type> <method name>(<parameter list>);
E.g. : float compute(float r);
Package
Package are container for classes, that are used to keep
the class name space compartmentalized
Packages are stored in a hierarchical manner and
packages are explicitly imported into new class
definition
The classes defined inside a package are not accessible
by the code outside that package.
Multithreading
Java provides built in support for multithreaded
programming.
A multi threaded programming contains two or more
parts that can concurrently.
Each part of a program is called thread.
Each thread has its own separate path of execution.
Multithreading makes the maximum use of CPU.