A.B.N &P.R.
R COLLEGE OF
SCIENCE,KOVVUR
SUBJECT: OBJECT ORIENTED
PROGRAMMING THROUGH JAVA
CLASS :IIB.SC(M.P.CS,M.S.CS,M.C.CS)
LECTURE : DELIVERED BY M.MURTHY
Java History
• Sun Micro systems developed object oriented programming
language in USA in 1990.
• Originally called Oak by James Gosling and his team.
• First it was developed for consumer electronic devices like
T.V, VCR’s, toaster etc.
• Later they developed a language that is simple, portable and
reliable.
• The language was modeled on C and C++ but removed a lot
of features of C and C++. That language is java
Features of java:-
Complied and Interpreted
Object oriented
Platform Independent and portable
Robust and secure
Distributed
Simple ,small and familiar
Multithreading
High performance
Dynamic and extensible
Compiled and Interpreted
• Usually a computer language is either compiled or
interpreted
• Java combines both these approaches, thus making
Java a two stage system
• First Java compiler translates source code into
byte code instructions
• Byte codes are not machine instructions
7
In the second stage Java interpreter generates machine
code• that can be directly executed by the machine
Fig. 2.1 Compiled and Interpreted
8
Object Oriented
1. Java is a true object oriented
•
language Almost everything in Java
•
is an object
2. All programs code and data reside within objects
•
and classes.
3. Java comes with an extensive set
of classes arranged in packages
9
Portable and platform independent:-
• The most significant feature of Java is
its portability.
• Java programs can be easily moved from one computer
system to another ,anywhere and at anytime with out
changing source code.
• Java Language is platform-independent because
java code can be run on any operating system .
Example:- windows, Linux,Unix, sun Solaris,
Mac/Os .
Platform Independent and Portable ..
• Changes and upgrades in
• Operating systems
• Processors
• System resources
will not force any changes in Java programs
11
Slogan of Java:-
“Write once and run any where”.
If you run your java program on any environment it
gives the same result because the size of primitive
data types are same in all platforms(OS).
Robust and secure
• Robust simply means strong. Java is robust because:
• Java is robust as it is capable of handling run-time errors, supports
automatic garbage collection and exception handling, and avoids explicit
pointer concept.
• Java has a strong memory management system. It helps in eliminating
errors as it checks the code during both compile and runtime.
• Java is garbage-collected language – JVM automatically deallocates the
memory blocks and programmers do not have to worry about deleting
the memory manually as in case of C/C++..
Robust and Secure
• Security is an important issue for any programming
language as there is a threat of malicious activities and
•
viruses. Java supports access modifiers to check
memory access and also ensures that no viruses enter
•
an applet.
• •Java is a more secure language as compared to C/C++,
as it does not allow a programmer to explicitly create
pointers
14
Distributed:-
Java is a distributed language which means that the
program can be design to run on computer networks.
It has the ability to share both data and programs
Simple ,small and familiar
• It is simple and small because it doesn’t use
pointers, storage classes, go to statements and
java doesn’t support multiple inheritances.
• It is familiar because it contains many features of
other languages like c and c++.
Multi-threading:-
A thread is an independent path of execution within a program,
executing concurrently. Multithreaded means handling multiple tasks
simultaneously or executing multiple portions (functions) of the same
program in parallel.
The code of java is divided into smaller parts and Java executes them in
a sequential and timely manner.
High Performance:-
Java programs exhibits high performance when compared with
“C” and “C++”.These programs are executed fastly . Java
programs are executed by Interpreter but it is slow ,
JITCOMPIER(JUST IN TIME COMPILER) fastens the
program execution.
Dynamic and Extensible
Java
• is a dynamic language. It is capable of linking
•
new Classes and libraries into memory when ever it
•
” is necessary.
•
•
Java is extensible because Java supports functions
written in other languages such as C and C++.These
functions are known as “native methods
19