History & Development of Java

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

HISTORY AND

DEVELOPMENT OF JAVA

James Gosling
James A. Gosling. (born on May 19, 1955, near
Calgary.
Alberta, Canada) is a famous software developer. In 1977, he
completed his graduation as a B.Sc. in Computer Science from
the University of Calgary. In 1981, he was honoured a Ph.D in
Computer Science from Carnegie Mellon He University.
developed many compilers and mail systems. Since 1984, he has
been associating with Sun Micro Systems and developed Java
programming language in 1991. He was also elected to the
United States National Academy of Engineering for this
achievement. In 2007, he was made an Officer of the "Order of
Canada", which is Canada's highest civilian honour.
Java is an object oriented programming
language developed primarily by James
Gosling and colleagues at Sun Micro Systems. This language was initially called Oak
(named after the Oak trees outside Gosling's office).
In 1991. the Sun Micro Systems (Broomfield, Colorado,
USA) developed a complete
language as a part of research work to develop software for consumer electronics. It was
developed as a full-fledged programming language in which one can accomplish the same
sort of tasks and solve the similar problems like other programming languages such as
BASIC, C++ etc. The platform independence is one of the most significant advantage that
JAVA has over other languages. It is the capability of
moving easily from one computer
system to another.
JAVA, being an object oriented programming language encapsulates many features of
C++. Originally, JAVA was designed to execute applets, downloaded while Web
browsing. But gradually, the language has been gaining wide acceptance as a
programming language, very often replacing C or C++.

Different types of Java programming


A Java program can be written in the following two ways:
Stand alone System (Java Application): A Java program, which is developed by the
user, is termed as Java Application.
4.lnternet Applets (Java Applets): The Java programs, which are down loaded from
he Internet and can be
applicable to the user's requirement are called Internet Applets.

Basic features of Java


Java
possesses the following features:
ava is an object oriented programming language.
and interpreted.
are both compiled
Java programs
independent.
Java programs are platform
language.
Java is a robust programming
It is multithreaded language.
as well as from net.
data from a local system
It can access variables and functions are declarod
a class. The
written within
Java programming is
class.
and defined with the which run on Web-browsers)
8) and
create Applets (the
programs
Java programs
can
languages.
like any other programming
general programs
of header files for creatina
are
Applications or inclusion a
any preprocessor
( #)
Java doesn't require
Java application program. and lower case letters
the upper case

Java is a case sensitive language. It distinguishes

Compiler and Interpreter


are the terms related
with language translation. Suppose,
Compilation and Interpretation
in New Delhi. He may not know any
Russian President has to address a gathering
a language
such situation, he is accompanied by
languages other than Russian. In
translator (a person) who can translate the speech
made by him in Russian language to
understand. The translation may take
Hindi or English for the people of New Delhi to
place in the following two ways:
After completion of the President's speech, the translator will communicate the whole
speech made by him in Hindi or English so that the people can understand. This type
of language conversion is termed as compilation and the person who does it is called

compiler.
As President finishes a sentence, it is immediately converted and spoken by the
translator in Hindi or English. In this system the translation is sentence wise. This
process of conversion of the language is called Interpretation and the translator is
termed as interpreter.
All high level languages need to be converted into machine code (binary code) so that
the computer understands the program after taking the required inputs. It processes the
program and then shows the desired result if it is error free, otherwise the errors are to
be corrected to execute the program
successfully.
The conversion of high-level language (source code) to machine level language
(binary code) can be done in two possible ways. It can be done either
or an Interpreter. by using a Compiler
The software, by which the conversion of the
high level instructions is performed ine
by line to machine level language, is known as an
any line, further execution stops till it is
Interpreter. If an error is found on
corrected. This process of error correction is
much easier but the program takes longer
time to execute
successfully.
Source Code Compiler/ Machine
Interpreter Code
Application Program System Program
Object Code
However, if all the
instructions are converted to machine level
together, then the software is known as language This
all the erors are listed at Once ad

ismuch faster but sometimes it


becomes difficult
Compiler. process
in a program. to debug (correct) all the errors together

Byte code & JVM


Java is high level language (HLL). The
a

conversion to an intermediate code called program written in Java is compiled for


machine on which the program is to run. This Byte code. This code is independent of the
makes a Java
its Bytes code can easily be
transferred from one program highly portable as
is to be un on any system another. When this Byte code
to
system, an interpreter, known as Java
needed which translates the byte code to Virtual Machine (JVM) is
machine code.

Windows
98
Java Java
Source Code Compiler Byte Code Java Unix
Interpreter Uni
System
JVM

OS-2
System
Java machine code varies for different
platforms like Windows, UNIX, OS-2 etc.
Hence, Java Interpreter converts byte code to the machine code for
JVM acts
concerning platform.
virtual processor, which processe the
as a
byte code to machine code
instructions for various platforms. That is why it is called
Java Virtual Machine.
Thus, the Java program uses compiler as well as interpreter both.

Java Libraries in JDK 1.3


Ihe Java
Development Kit (JDK) contains a Java Class Libraryfor different purposes.
SOme useful
packages in the Java Class Library are mentioned below:
Java.lang: to support classes containing String, Character, Math, Integer, Thread etc.
Jjava.io :to support classes to deal with input & output statements.
Java.applet: to support classes to generate applet - specific environnment
java.net :to support classes for network related operations and dealing with URL
(Uniform Resource Locator)
Jawa.awt:to support abstract window tool kit and also to manage GUI (Graphic
User Interface)
java.txt f o r supporting text elements such as dates, times and currency etc.
Jvd.math : to support mathematical function such as square roots (integer &
decimal both)
17
JAVA Reserved Words are preerved with
the systerm. Thes
are those
words, which
words has reserved word
Rexerve words or key als
Java
name in any prograrn,
be applied as a variable reference
words cannot below for your
words are listed
Some of the reserved/key static
break
Switch else
case
float char
Const
throws
do void goto
double
int boolean
try import
while new
for package private
if byte default
long class
catch short public

in Java Programming
Comment Statements the logic applied in a program
to understand
becomes difficult for
a user
Sometimes it the programmer keeps
has developed it. In such cases.
other person This can be made
particularly when any in different steps.
and action being taken
mentioning the purpose statement in the program.
comment
possible only by applying However. users are
in Java programming.
give a comment
There are three ways to Java programming.
wherever necessary while writing
expected to give comments

used for single line comment

1.
used for multi line
comment
2. /* comments to be written */ :
comment */
3. /** documenting

Single Line comment


in short ie.
the purpose of a logical step
This comment symbol is applied to explain
within a line. An example is given below:

class first

public static void main (String args[ )

/ This is my first program


int a= 5,b = 8,c;

Ca+ b// Find the sum of two nunmbers

System.out.printin("Sum of two numbers"+c):

Multl Line Comment


the
Multi Line comment statement can be used when the pogrammer
wants to explain
in details L.e, by including multiple linen an ahown below
louical steps
class firn
public static void main
(String args[ })
/*This is my first
program.
It is
developed on 28/04/05.
The program is to show multi line comment
int
statement. *1
a= 5,b =
8.c:
c= a+ b:// Find the sum of two numbers
System.out.println("Sum of two numbers =" +c):

Documenting Comment
This type of comment statement
can be
brief documentation along with his applied when a
programmer needs to include
program.
class first

public static void main (String args[ ])


/8 My name is Poulomi Dey.
study in Rajendra Vidyalaya in Std. VIlI B.
This is my first program in Java
int a= 5,b
language.*/
8,c; =

c a+ b:/I Find the sum of two


numbers
System.out.println("Sum of two numbers =" +c);

Output Statement in Java


Programming
When you use System.out.println ( ) statement, the cursor
the next line after displaying the
skips the line and passes to
required result.
However, the cursor remains on the same line after displaying the result if we use
System.out.print( ).
These statements are used to get the
output of the program or to
display messages on
the screen which are shown below:
Syntax: System.out.println("Welcome to Java Programming");
Note: The message is to be written within double quotes (" ")enclosed
within braces.

Syntax: System.out. println("The sum of two numbers is" + a );

Note: When a message is to be displayed along with a variable, then they are to
be separated with +" (plus) sign.
Introduction to BlueJ
environment from Monash University, Australia. It is a wind
w based
BlueJ is a free Java
Kit (JDK ). It requires to install JDK 1.3 versionsed
on or more
platform for Java Development
also get more intormation about BlueJ throuore
before installing Blue). We can ugh the
website www.bluei.monash.edu.
Blue) can be freely downloaded from the
www.bluei.org.
Features of BlueJ
.The compilation as well as execution process IS comparatively easier than
Java
(JDKI.3).
It is menu driven approach. Hence. it makes the system easier for the userto
Work on
windows platform.
.To inculcate good programming skills, a sample program appears on the screen as co
on
as the user defines a class.
After compilation, it shows the error, if any, present in the program. Otherwise t
displays the message "No syntax error".
You can also down load Java program from Internet.
a

You can also share programs from Non-BlueJ environment.

How to start BlueJ


You have to
perform the following steps to start BlueJ and to write a BlueJ
platform: program on

At first, double click the BlueJ


on icon, which is present on the desktop.

BlueJ
Monash University
University of Southern
Denmark
Shortcut
to bluej Version 1.2.2
You can see project option on menu bar of BlueJ windows, which enables you to
create a directory. In order to create a directory, click on project and then select new
project option.

BlueJ
Project Edit Tools View
Help
New Class

Step-I
Compile

View
Uses
Inheritance

Creating virtual machine..Done

BlueJ
roject Ed Tools Vlew
OX
Nelp
w Project...
Open Project... Ctrl-o
Open Recent
Open Non BlueJ.
Close Ctr-W
Step-II
Save Cir-S

Save As.
Import..
Export.
Page Setu..
Print.. Cr-P

Quit Ctr-a

Creating virtual machine... Done

21
the space
provided in theEile
the name in

is created
after typing with the Project icon, N
Now
project/directory screen appears
A The
click create.
Name (say, Learning) and
button.
click on New Class

Help
aBlueJ Wiew
Project Edit Tools

New Project
Look In: Step-III
Abhinav
AKASH
Asrani
Blue
convent
Dey constructor
Dey Inheritence
dk
DKClass
Create
Flle name: Learning
Cancel
Flles ofype: All Files (-)

BlueJ- Learning
Project Edlt Tools View Help

New Class

Step-IV
Compile

View
Uses

Inheritance

RSEEgzEEEHISEgggE SggIEEggggggggzsEB233355SESSeeesrsesse
Write Class Name in the space provided (say, Welcome) and click OK. A new window
appears with the folder named Welcome.

BlueJ -

Create New Cl.. X


Class Name
Welcome Step-V

Class Type
OClass
O Abstract Class

OInterface
O Applet
OApplet
O Unit Test

Ok|Cancel

BlueJ- Learning
Project Edit Tools View Heip

New Class
Welcome
Step-VI
Compile

View
Uses
Inheritance

Now, just double click the folder Welcome to open the class Welcome. A sample
structure of the class appears on the screen.

23
Welcome
tass B Teets epties
mplementation

Compile Undo ut Copy PasteClos


Step-VII
* here.
Melcome
class
rite a description of

author
euthor nmber or
(a varaion mber or a date date
pulic claes Molc
om
ewAple below with your
variablee replace the
Anstance
/private int n:

for objects of elans Nelcome


Conetructor

poblie Melome ()
A n i t i a l i s e instance variables

thie caent with your on


replace
mo thod
-

AD e p l e of a

eparan Y sAple parme ter for a me thod

ersturn thesumof x and


Cnged

Select and delete the sample structure.

Welcomne
Cless BR Tools Outons
Compile Undo Cut CoPY Paste Close Irnplernentstion
/**
Write a description of clase Helcome bare. Step-VIII
dauthor (your nane)
eauthor (a version mumber or a date)
Pablic class Welcom

linstance variables replace the exaple belou vith your on


private int
Constructor for objects of class Holcom

blie Welcame ()

initialise instance variables

An eple of a thod replacs this


coment with your om

eparan Y
ereturn the ple paraster for
tora a nothod
nothod
and

changeo
Now, you start
writing your program as illustrated below.
which displays the message: "Class Compile your
Otherwise, debug and recompile the compiled, no syntax errors" (if noprogram
program unless it is error).
error free.
Welcome
Class BilR Toois Options

Compile Undo Cut Copy Paste Close


Implementation
public class Welccme
Step-IX
public statie void main (String args[1)
II A Sample Java
1/ By Vijay & Programing
Dilip
System.out.println(
Syatem.out.println
"Hellow Java ")
("Welcome to Java
Programing with BlueJ") ;

Class compiled no syntax errors


Saved
24
Description of the
program
Line 1 :
Declaration of a class i.e
Line 2
:Opening of the class with (Public class Welcome)
Line 3 :It contains the main()
from the main) function. The execution of
function the file commences
public :declares that the function
access has no
static a
key word that instructs the restriction
before any thing else in the compiler that main() should be run
Void It program
indicates that main) will
return any value. not
String args[ ] : It declares a
string array, 'args' stands for
.Line 4 It indicates the arguments
starting of the main() by a opening brace
Lines5-6 :These are comment
Line 7-8
lines
These are only executable
statements of the
System.out.println("Hello program. 1.e
Java")
Java Programming") System.out.println("Welcome to
Line 9
closing brace }, to close the main function
Line 10
closing brace }, to close the class.
Compilation of Java program
After writing a Java Program, it is to be
compiled and then only the program can be
executed. On the screen, click the
at the bottom of
option compile. If the program doesn't have error then
the screen a message
click close and thus, it closes the classdisplays
"class compiled no syntax error" Now, -

(program) for the execution.


Execution of Java Program
The following steps are to be done to execute a Java Program:
.Select the icon of the class (say Welcome) on the screen and click the right button
of the mouse

BlueJ- Learning
Project Edit Tools View
Help
New Classs
Welcomee
new Wecome() Step-X
VOlo rmainarg
Compile Open Editor
Compile
Remove

View

Uses
Inheritance

.A drop down menu appears on the screen. Now select and


click void main (args).
A M e n o a call WindoW appcals

BlueJ-1Learning
Prolect EiR Teols View Help

New Class Welcome


Step-XI

Compile Blue: MethodCall


voidmain(String args)

View
Welcome.main( |0
Uses Ok Cancel
Inheritance

The desired output of the


program is seen on the screen as
shown below,
aBluel: Terminal Window
Options
Bellow Java !
Welcome to Java
Programming with BlueJ
I have got the
output

Note In case
of using input statement
from the user
in the
program, the system asks the
thus obtained. (discussed in the
Chapter 5). value
The
output of the
program is
Modification in Java
If
you want to Programming
Welcome) modify
(say the
and double present program, which is
appears on the click the left on
Bluej
It must be
screen where you can
button of the platform,
mouse. Thus, select the class
the output.
noted that the modify your the desired
program has to be program. progranm
recompiled after making
any change to get

26
pifferences between JDK 1.3 and
Bluel
JDK 1.3
BlueJ
1.DOS based platform.
. Windows based platform.
2. Uses DOS command for
compilation 2. Uses menu driven approach
for compilation.
3. Sample program does not appear 3.
Sample program appears on the
Screen.
4. Provides interaction to the user. 4. It provides user-friendly environment.

Exercise
Multiple choice questions
I. Tick () the correct answer:

1. A program of Java that be


can developed and executed by the users, is
known as:
(a) Application b) Applet
(c) Object (d) none
2. Who developed Java?
(a) James Gosling (b) Robert James
(c) Bjarne Stroustrup (d) None
3. Java Virtual Machine (JVM) is an:
(a) Interpreter (b) Compiler
(c) Machine code (d) Byte code
4. Java is case sensitive. What is most appropriate with respect to this context?
(a) Upper and lower case letters are distinguished.
(b) Upper and lower case letters are ignored.
(c) Only lower case letters are distinguished.
(d) None.
5. To find the square root of a number which of the following package is
required?
(a) java.txt (b) java.math
(c) java.lang (d) java.net
Java reserved word?
6. Which of the following is not a

(a) private (b) public


(c) break (d) character
7. Which is most suited to BlueJ?
(a) A Window based plattom.
(6) A DOS based platform.
(c) A Window based and DOS based.
(d) None.
8. In a Java Program, The comments are Written using:
(a) (b)*...*
(c) *...*/ (d) Both (a) and (c).
9. The term used to correct the error in a program, is known as:
(a) bug (6) debugging
(c) error removing (d) none
II. Indicate whether the following statements are TRUE or FALSE:
1. Java language can use
applications but not
applets.
2. Java language was
developed by Sun micro system.
3. Java language uses compiler but not an
interpreter.
4. Byte code and machine code are
synonyms.
5. JVM converts byte code to machine
code.
6. Source code is also called an
object program.
7. Reserved words also referred
are as key words.
8. Multi line comments are same as documentation
comments.
9. BlueJ is not a menu based
approach.
10. print() and println() produce the same effect in the
presentation of output.
III. Predict the
output of the snippet:
1.
System.out.println("This is my first Java
program");
System.out.println("Display the message");
System.out.println("Have a fun!!");
2.
System.out.printin("My name is Gulam Ali ");
System.out.println("I student of Class
am a
X");
System.out.print("My hobby is:");
3.
System.out.println("Concept on Misconcept")
System.out.print("The factorial of 5 is "):
System.out.println(" 120 ");
4. System.out.print("15h.August")

System.out.print("1947, is a red letter


day. ");
System.out.printin("We should sacrifice
ourselves for the sake of
the Nation.");
28
IV. Write short answers:
1. What is Java? What
was it
called
2. What are the features initially?
of Java?
3. Briefly State the ICSE 2005
development of Java.
4. Explain the significance of the Java
(a) java.lang library packages.
(b) java.io (c) java.math
5. (a) Name two different styles of expressing a comment in Java
programming.
(b) Name two [ICSE-2005)
types of Java programs.
6. What are the different [ICSE-2007]
ways to give comnent in Java
7. Give an
example of each with reference
Programming?
to Java
(a) Single Line comment programming:
(b) Multi Line comment
8. Define the terms:
(a) Source code
(b) Machine code (C) Byte code
9. Distinguish between:
(a) Compiler and Interpreter (b) Java (JDKI.3) and
10. What is BlueJ? What are
Blue
the features of BlueJ?
11. Write down the syntax of
output statement in Java
programming with an
example?
12. What do you understand by Java reserved words? Name at least five Java
reserved words which are commonly used in Java
programming
13. Write Java program with class name Learning
a to display the message
"BEST WISHES FOR THE NEW YEAR".
14. Write down all the steps to compile
Java program.
and execute a

15. What is the significance of JVM in java programming?


16. A Java program uses a Compiler as well as an Interpreter. Explain.
17. Distinguish between System.out.print() and System.out.println.
18. Name a Java package, which is imported by default.
19. Why JVM is termed as a machine although it is software?
20. How can you modify a Java program on BlueJ platform?

29

You might also like