History of Java
History of Java
Java language developed by company Sun Microsystems and creator is Jamesh Gosling.
James Gosling and his team members given the project name as Green started in the year 1990
and common remote control completed in the year 1992.
The James Gosling team develop a new language called as OAK But this name is already
selected by some other company renamed as Java but java has no meaning representation of
Island in Indonesia. The unofficial abbreviation of java is Just another virtual analyzer
(JAVA).
Overview of Java
Java is one of the programming language or technology used for developing web applications.
Java language developed at SUN Micro Systems in the year 1995 under the guidance of James
Gosling and there team. Originally SUN Micro Systems is one of the Academic university
(Standford University Network)
Whatever the software developed in the year 1990, SUN Micro Systems has released on the
name of oak, which is original name of java (scientifically oak is one of the tree name). The
OAK has taken 18 months to develop.
The oak is unable to fulfill all requirements of the industry. So James Gosling again reviews this
oak and released with the name of java in the year 1995. Scientifically java is one of the coffee
seed name.
J2SE
J2SE is used for developing client side applications.
J2EE
J2EE is used for developing server side applications.
J2ME
J2ME is used for developing mobile or wireless application by making use of a predefined
protocol called WAP(wireless Access / Application protocol).
Features
Java Version SE 6
Features
Generics
Enhanced for Loop
Autoboxing/Unboxing
Typesafe Enums
Varargs
Static Import
Metadata (Annotations)
Instrumentation
XML Processing
Java Print Service
Logging API
Java Web Start
JDBC 3.0 API
Assertions
Preferences API
Chained Exception
IPv6 Support
Regular Expressions
Image I/O API
Java Sound
Jar Indexing
A huge list of enhancements in almost all the java area.
Features
Collections framework.
Java String memory map for constants.
Just In Time (JIT) compiler.
Jar Signer for signing Java ARchive (JAR) files.
Policy Tool for granting access to system resources.
Java Foundation Classes (JFC) which consists of Swing 1.0, Drag and Drop, and Java 2D class
libraries.
Java Plug-in
Scrollable result sets, BLOB, CLOB, batch update, user-defined types in JDBC.
Audio support in Applets.
Features
Features of Java
Features of a language are nothing but the set of services or facilities provided by the language
vendors to the industry programmers. Some important features of java are;
Simple
Platform Independent
Architectural Neutral
Portable
Multi Threading
Distributed
Networked
Robust
Dynamic
Secured
High Performance
Interpreted
Object Oriented
1. Simple
It is simple because of the following factors:
It is free from pointer due to this execution time of application is improve. [whenever we write
a Java program without pointers then internally it is converted into the equivalent pointer
program].
It have Rich set of API (application protocol interface).
It have Garbage Collector which is always used to collect un-Referenced (unused) Memory
location for improving performance of a Java program.
It contains user friendly syntax for developing any applications.
2. Platform Independent
A program or technology is said to be platform independent if and only if which can run on all
available operating systems with respect to its development and compilation. (Platform
represents O.S).
3. Architectural Neutral
A Language or Technology is said to be Architectural neutral which can run on any available
processors in the real world without considering there architecture and vendor (providers)
irrespect to its development and compilation.
The languages like C, CPP are treated as architectural dependent.
4. Portable
If any language supports platform independent and architectural neutral feature known as
portable. The languages like C, CPP, Pascal are treated as non-portable language. It is a portable
language.
According to SUN microsystem.
5. Multithreaded
A flow of control is known as thread. When any Language execute multiple thread at a time that
language is known as multithreaded Language. It is multithreaded Language.
6. Distributed
Using this language we can create distributed applicationn. RMI and EJB are used for creating
distributed applications. In distributed application multiple client system are depends on multiple
server systems so that even problem occurred in one server will never be reflected on any client
system.
Note: In this architecture same application is distributed in multiple server system.
7. Networked
It is mainly design for web based applications, J2EE is used for developing network based
applications.
8. Robust
Simply means of Robust is strong. It is robust or strong Programming Language because of its
capability to handle Run-time Error, automatic garbage collection, lack of pointer concept,
Exception Handling. All these points makes It robust Language.
9. Dynamic
It support Dynamic memory allocation due to this memory wastage is reduce and improve
performance of application. The process of allocating the memory space to the input of the
program at a run-time is known as dynamic memory allocation, To programming to allocate
memory space by dynamically we use an operator called 'new' 'new' operator is known as
dynamic memory allocation operator.
10. Secure
It is more secured language compare to other language; In this language all code is covered into
byte code after compilation which is not readable by human.
This language uses Bytecode which is more faster than ordinary pointer code so Performance of
this language is high.
Garbage collector, collect the unused memory space and improve the performance of
application.
It have no pointers so that using this language we can develop an application very easily.
It support multithreading, because of this time consuming process can be reduced to execute
the program.
12. Interpreted
Java is a platform independent programming language, Because when you install jdk software on
your system then automatically jvm are install on your system. For every operating system
separate jvm is available which is capable to read .class file or byte code. When we compile
your java code then .class file is generated by javac compiler these code are readable by jvm and
every operating system have its own jvm so jvm is platform dependent but due to jvm java
language is become platform independent.
Operation of JVM
JVM mainly performs following operations.
JVM is separately available for every Operating System while installing java software so that
JVM is platform dependent.
Note: Java is platform Independent but JVM is platform dependent because every Operating
system have different-different JVM which is install along with JDK Software.
Heap area:
Method area
Java Stack
In which all the non-static variable of class will be stored and whose address referred by object
reference.
Pc Register
Which holds the address of next executable instruction that means that use the priority for the
method in the execution process?
Native Stack
Native stack holds the instruction of native code (other than java code) native stack depends on
native library. Native interface will access interface between native stack and native library.
Execution Engine
Which contains Interpreter and JIT compiler whenever any java program is executing at the
first time interpreter will comes into picture and it converts one by one byte code instruction into
machine level instruction JIT compiler (just in time compiler) will comes into picture from the
second time onward if the same java program is executing and it gives the machine level
instruction to the process which are available in the buffer memory.
Note: The main aim of JIT compiler is to speed up the execution of java program.
JIT is the set of programs developed by SUN Micro System and added as a part of JVM, to speed
up the interpretation phase.
In the older version of java compilation phase is so faster than interpretation phase. Industry has
complained to the SUN Micro System saying that compilation phase is very faster and
interpretation phase is very slow.
So solve this issue, SUN Micro System has developed a program called JIT (just in time
compiler) and added as a part of JVM to speed up the interpretation phase. In the current version
of java interpretation phase is so faster than compilation phase. Hence java is one of the highly
interpreted programming languages.
Class: Class is a blue print which is containing only list of variables and method and no memory
is allocated for them. A class is a group of objects that has common properties.
Data Member
Method
Constructor
Block
Class and Interface
State
Behavior
Identity
Behavior: Represents the behavior (functionality) of an object such as deposit, withdraw etc.
Identity: Object identity is typically implemented via a unique ID. The value of the ID is not
visible to the external user. But,it is used internally by the JVM to identify each object uniquely.
In real world many examples of object and class like dog, cat, and cow are belong to animal's
class. Each object has state and behaviors. For example a dog has state:- color, name, height, age
as well as behaviors:- barking, eating, and sleeping.
Vehicle class
Car, bike, truck these all are belongs to vehicle class. These Objects have also different different
states and behaviors. For Example car has state - color, name, model, speed, Mileage. as we;; as
behaviors - distance travel
Difference between Class and Object
Class Object
No memory is allocated at the time of Sufficient memory space will be allocated for all the variables
2
declaration of class at the time of declaration.
Output
Employee ID: 101
Name: Hitesh
Note: A new keyword is used to allocate memory at runtime, new keyword is used for create an
object of class, later we discuss all the way for create an object of class.
In general every programming language is containing three categories of data types. They are
Example
int a; // valid
a=10; // valid
a=10, 20, 30; // invalid
Here "a" store only one value at a time because it is primitive type variable.
Example
int a[] = {10,20,30}; // valid
int b[] = {100, 'A', "ABC"}; // invalid
Here derived data type store only same type of data at a time not store integer, character and
string at same time.
User defined data types related variables allows us to store multiple values either of same type or
different type or both. This is a data type whose variable can hold more than one value of
dissimilar type, in java it is achieved using class concept.
Note: In java both derived and user defined data type combined name as reference data type.
In C language, user defined data types can be developed by using struct, union, enum etc. In java
programming user defined datatype can be developed by using the features of classes and
interfaces.
Example
Student s = new Student();
In java we have eight data type which are organized in four groups. They are
Integer category data types are divided into four types which are given in following table
3 Int 4 + x to - (x+1)
4 Long 8 + y to - (y+1)
A character is an identifier which is enclosed within single quotes. In java to represent character
data, we use a data type called char. This data type takes two byte since it follows Unicode
character set.
Double 8 + 9.223*1018 16
Boolean data type takes zero bytes of main memory space because Boolean data type of java
implemented by Sun Micro System with a concept of flip - flop. A flip - flop is a general purpose
register which stores one bit of information (one true and zero false).
Note: In C, C++ (Turbo) Boolean data type is not available for representing true false values but
a true value can be treated as non-zero value and false values can be represented by zero
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte
Syntax
Variable_name = value;
Note: Actually a variable also can start with ¥,¢, or any other currency sign.
Output
Sum is : 100
Variable declarations
In which sufficient memory will be allocated and holds
default values.
Syntax
Datatype variable_name;
byte b1;
Variable initialization
It is the process of storing user defined values at the time of allocation of memory space.
Variable assignment
Value is assigned to a variable if that is already declared or initialized.
Syntax
Variable_Name = value
int a = 100;
Syntax
int a= 100;
int b;
b = 25; // ------> direct assigned variable
b = a; // ------> assigned value in term of variable
b = a+15; // ------> assigned value as term of expression
Operators in Java
Operator is a special symbol that tells the compiler to perform specific mathematical or logical
Operation. Java supports following lists of operators.
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Ternary or Conditional Operators
Arithmetic Operators
Given table shows all the Arithmetic operator supported by Java Language. Lets suppose
variable A hold 8 and B hold 3.
Relational Operators
Which can be used to check the Condition, it always return true or false. Lets suppose variable A
hold 8 and B hold 3.
Assignment operators
Which can be used to assign a value to a variable. Lets suppose variable A hold 8 and B hold 3.
Ternary operator
If any operator is used on three operands or variable is known as ternary operator. It can be
represented with " ?: "
Main() Method
main() method is starting execution block of a java program or any java program start their
execution from main method. If any class contain main() method known as main class.
Syntax of main() method:
Syntax
public static void main(String args[])
{
.......
.......
}
Public
public is a keyword in a java language whenever if it is preceded by main() method the scope is
available anywhere in the java environment that means main() method can be executed from
anywhere. main() method must be accessed by every java programmer and hence whose access
specifier must be public.
Static
static is a keyword in java if it is preceded by any class properties for that memory is allocated
only once in the program. Static method are executed only once in the program. main() method
of java executes only once throughout the java program execution and hence it declare must be
static.
Void
void is a special datatype also known as no return type, whenever it is preceded by main()
method that will be never return any value to the operating system. main() method of java is not
returning any value and hence its return type must be void.
String args[]
String args[] is a String array used to hold command line arguments in the form of String
values.
In case of main() method following changes are acceptable
String[] args
String args[]
String []args
Syntax
main(String[] args) --> main(String... args)
Syntax
public static we can take static public
Syntax
public static void main(String a[])
Example
public class mainclass
{
public static void main(String[] args)
{
System.out.println("Execution starts from Main()");
}
void main(int args)
{
System.out.println("Override main()");
}
double main(int i, double d)
{
System.out.println("Override main()");
return d;
}
}
Output
Execution starts from Main()
Output
Argument is: Porter
Output
Sum: 30
When the above statement is executing the following sequence of steps will take place.
Class loader sub-system loads SumDemo along with Command line argument(10, 20)
and in main memory.
JVM take the loaded class SumDemo along with Command line arguments (10, 20) and
place the number of values in the length variable that is 2.
JVM looks for main() that is JVM will place the Command in the main() in the form of
string class that is.
Hence all the CMD line arguments of java are sending to main() method available in the
form of array of object of String class (every CMD are available or stored in main
method in the form of array of object of String class).
JVM calls the main() method with respect to loaded class SumDemo that is
SumDemo.main().
Note: Except + operator any numeric operation not allowed in command line arguments.