0% found this document useful (0 votes)
162 views23 pages

Java Programming Overview for BCA 5th Sem

The document discusses Java as an object-oriented programming language. It was developed by James Gosling and his team at Sun Microsystems in 1991. Java code is first compiled to bytecode, then interpreted by the Java Virtual Machine (JVM) allowing it to run on any device. This makes Java both compiled and interpreted.

Uploaded by

Roopa s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views23 pages

Java Programming Overview for BCA 5th Sem

The document discusses Java as an object-oriented programming language. It was developed by James Gosling and his team at Sun Microsystems in 1991. Java code is first compiled to bytecode, then interpreted by the Java Virtual Machine (JVM) allowing it to run on any device. This makes Java both compiled and interpreted.

Uploaded by

Roopa s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Object Oriented

Programming Language
using Java
BCA 5th Sem – Prepared by Roopa S
JAVA PROGRAMMING

• Who has developed java?

Java was developed by James Gosling and his team,


at Sun Microsystems of USA in 1991.
History of Java

Java is a general-purpose, object-oriented programming language


developed by James Gosling and his team at Sun Microsystems of USA
in 1991.

Java was designed for the development of software for consumer


electronic devices like TVs, VCRs and such other electronic machines.
History of Java

The development team modeled their new language Java on C and C++.

But they removed a number of features of C and C++ that was


considered as sources of problems

Java was made as a really simple, reliable, portable ,object oriented


programming language
Timeline of Java Development
• 1990 - Sun Microsystems decided to develop a special software that
could be used to manipulate consumer electronic devices.
• 1991 -The team announced a new language named “oak”.
• 1992 -The team demonstrated the application of their new language to
control a list of home application using a hand-held device.
• 1993 - The team came up with the idea of developing Web applets
using the new language.
• 1994 -The team developed a Web-browser called “Hotjava”.
• 1995 - “Oak” was renamed “Java” due to some legal snags.
Types of Java Program
1. Java Application Programs - Programs that run on stand alone system.

class student
{
int roll_no;
void getdata ( )
{ Java statements…;
}
}
Types of Java Program
2. Java Applets -
An applet is a Java program that runs in a Web browser.
When a user views an HTML page that contains an applet, the code for
the applet is downloaded to the user's machine.
A JVM is required to view an applet.
Difference between Application Programs and Applet Programs

Application Programs Applet Programs


Stand alone programs These programs are used in
Internet Applications
Program execution begins from No main ( ) in applet
main() Applet first uses run ( ) method
in its life cycle
Requires Java compiler and Requires Java compiler and Java
interpreter to execute the enabled web browser
program
Application programs can be Applets cannot be written to
written to a file files
Java is a purely Object Oriented Programming
Language. Why ?
1. Java supports various features of an object oriented
programming language such as
 Abstraction,
 Encapsulation,
 Inheritance,
 Polymorphism
Java is a purely Object Oriented
Programming Language. Why ?
2. Java was developed by James Gosling at Sun Microsystems in the year
1991 and has been gaining popularity every since.

3. Before java, the industries were using the two main languages C and C++.
4. C is simple, powerful and procedural language.
5. C++ is object oriented, but also more complex and requires great deal of
overhead to maintain the program.
6. Both languages are machine-dependent, which means that C and C++
programs only run on same environment. The program must be recompiled
on another environment for the compilation.
7. Java is inherited the power and flexibility from C language and
object- oriented features from C++ without the overhead.

8. And also in java the complete code we have to write inside a class
and we can access the methods by creating an object of their
respective built-in classes.
Hence we can say that “Java is fully Object - Oriented”.
List some differences between C and Java
C Java

1 C is a procedure oriented language Java is a pure object oriented programming


language

2 C has goto , sizeof, typedef keyword Java does not support

3 C has pointers Java does not support

4 C supports struct, union, enumdata type Java does not support

5. C++ has header files Java has no header files , only packages
List some differences between Java and C++
C ++ Java

1 C++ is a superset of C Java is the superset of C and C++

2 C++ supports operator operloading Java does not support

3 C++ has pointers Java does not support

4 C++ supports multiple inheritance Java uses interface to support the same
concept

5. C++ has header files Java has no header files , only packages
Features / Characteristics of Java
1. Platform Independent.
 Java program can be easily moved from one computer system to another, anywhere and
anytime.
 Changes and upgrades in operating systems, processors, and system resources will not force
any changes in java programs.
2. Portable

 Portable refers to the ability of a program to run on any platform without changing the
source code.
 The programs developed on one computer can be run on another computer.
 Java compiler converts source file to a bytecode file. The bytecode can be executed on any
platform.
Features / Characteristics of Java
3. Object-Oriented.
 Java supports the object oriented approach to develop programs.
 It supports various features of an object oriented programming language such as abstraction, encapsulation, Inheritance,
polymorphism etc.
4. Secure.
 Java is intended to work in network and distributed environment by providing security.
 The absence of pointers in java ensures that programs cannot gain access to memory locations without proper authorization.
 Java compiler generates Bytecode instructions that can be implemented on any machine. And also it is very secure code.

5. Distributed.
 Java is used to develop application that can be distributed among various computers on the network.
 Java supports various Internet protocols, such as TCP, IP etc.
Why Java is both a compiled and interpreted
language?
Java can be considered both a compiled and an interpreted
language because

1. Its source code is first compiled into a binary byte-code.

2. This byte-code is interpreted using the Java Virtual Machine (JVM)


which is usually a software-based interpreter.
What are bytecode?
• Bytecode in Java is the reason java is platform-independent, as soon
as a  Java program is compiled bytecode is generated.

• It is in the form of a .class file.

• A bytecode in Java is the instruction set for Java Virtual Machine 


(JVM) and acts similar to an assembler.
What is bytecode and machine code?
• The main difference between the machine code and the bytecode is
that the machine code is a set of instructions in machine
language or binary which can be directly executed by the CPU.

• While the bytecode is a non-runnable code generated by compiling a


source code that relies on an interpreter to get executed.
.java file

.class file

.obj file
Here is the sequence of things normally happens from writing to execution of a Java
program :

1. Programmer write source code and store that into a .java file.

2) javac compiles .java fie and creates class files, which contains byte


code.

This byte code remains same on all platforms.


It is the main reason of Java being platform independent.

3) JVM executes these class files and gathers statistics of execution
run. These statics are used to determine hot spot i.e. part of your
code which executes 90% of time.

4) After certain threshold, when JVM has enough data to make


decision, JIT compiles frequently used byte codes into native code,
which is then directly executed by platform. This provides
performance boost to Java application.

Hence , Java is both compiled and interpreted language.

You might also like