0% found this document useful (0 votes)
91 views22 pages

Lecture 1

The document provides an introduction to object-oriented programming and Java. It discusses the history and features of Java, including how it is compiled and interpreted, its object-oriented nature, platform independence, security, and use for internet programming.

Uploaded by

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

Lecture 1

The document provides an introduction to object-oriented programming and Java. It discusses the history and features of Java, including how it is compiled and interpreted, its object-oriented nature, platform independence, security, and use for internet programming.

Uploaded by

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

Introduction to Object

Oriented Programming

LECTURE ONE

Mahamudul Hasan
Senior Lecturer, Dept of CSE, EWU
BOOK’S NAME

1. Introduction to Java Programming by Daniel Liang


2. Java the Complete Reference, 11th Edition, Author:
Herbert Schildt
3. Java™ How to Program, Early Objects, 11th Edition, Author:
Paul Deitel, Harvey Deitel
Web Source:
 http://docs.oracle.com/javase/tutorial/
HISTORY OF JAVA
 Java is a general purpose object oriented programming
language.
 Developed by Sun Microsystems. (James Gostling)
 Initially called “Oak” but was renamed as “Java” in
1995.
 Initial motivation is to develop a platform independent
language to create software to be embedded in various
consumer electronics devices.
 Become the language of internet. (portability and
security).
FEATURES OF JAVA
1. Simple, Small and Familiar
2. Compiled and Interpreted
3. Object Oriented
4. Platform Independent and portable
5. Robust and Secure
6. Distributed / Network Oriented
7. Multithreaded and Interactive
8. High Performance
9. Dynamic
SIMPLE, SMALL AND FAMILIAR
Similar to C/C++ in syntax
But eliminates several complexities of
No operator overloading
No direct pointer manipulation or pointer arithmetic
No multiple inheritance
No malloc() and free() – handles memory automatically
COMPILED AND INTERPRETED
Java works in two stage
Java compiler translate the source code into byte code.
Java interpreter converts the byte code into machine
level representation.
Byte Code:
A highly optimized set of instructions to be executed by
the java runtime system, known as java virtual machine
(JVM).
Java Virtual Machine (JVM):
JAVA VIRTUAL MACHINE
 Java compiler produces an intermediate code known as byte
code for a machine, known as JVM.
 It exists only inside the computer memory.

Java Program Java Compiler Virtual Machine

 Machine code is generated by the java interpreter by acting


as an intermediary between the virtual machine and real
machine.

Bytecode Java Interpreter Machine Code


OBJECT ORIENTED
Fundamentally based on OOP
Classes and Objects
Efficient re-use of packages such that the programmer only
cares about the interface and not the implementation
The object model in java is simple and easy to extend.
PLATFORM INDEPENDENT AND
PORTABLE
“Write-Once Run-Anywhere”
Changes in system resources will not force any change
in the program.
The Java Virtual Machine (JVM) hides the complexity of
working on a particular platform
Convert byte code into machine level representation.
ROBUST AND SECURE
Designed with the intention of being secure
No pointer arithmetic or memory management!
Strict compile time and run time checking of data type.
Exception handling
It verify all memory access
Ensure that no viruses are communicated with an applet.
DISTRIBUTED AND NETWORK
ORIENTED
 Java grew up in the days of the Internet
 Inherently network friendly
 Original release of Java came with Networking libraries
 Newer releases contain even more for handling distributed
applications
MULTITHREADED AND INTERACTIVE
Handles multiple tasks simultaneously.
Java runtime system contains tools to support
multiprocess synchronization and construct smoothly
running interactive systems.
HIGH PERFORMANCE
Java performance is slower than C
Provisions are added to reduce overhead at runtime.
Incorporation of multithreading enhance the overall
execution speed.
Just-in-Time (JIT) can compile the byte code into
machine code.
 Can sometimes be even faster than compiled C
code!
DYNAMIC
Capable of dynamically linking a new class libraries,
methods and objects.
Java can use efficient functions available in C/C++.
Installing new version of library automatically
updates all programs
LANGUAGE OF INTERNET
PROGRAMMING
Java Applets
Security
Portability
1. Applets:
Special java program that can transmitted over the network
and automatically executed by a java-compatible web
browser.
2. Security:
Java compatible web browser can download java applets
without fear of viral infection and malicious agent.
3. Portable:
Java applets can be dynamically downloaded to all the
various types of platforms connected to the internet
WHY PORTABLE AND SECURE?
.
The output of java compiler is not executable code.
Once JVM exists for a platform, any java program can run
on it.
The execution of byte code by the JVM makes java
programs portable.
Java program is confined within the java execution
environment and cannot access the other part of the
computer.
BASICS OF JAVA ENVIRONMENTS
Java programs normally undergo five phases
Edit
Programmer writes program (and stores program on disk)
Compile
Compiler creates bytecodes from program
Load
Class loader stores bytecodes in memory
Verify
Verifier ensures bytecodes do not violate security
requirements
Execute
Interpreter translates bytecodes into machine language
Program is created in an
Phase 1 Editor Disk editor and stored on disk
in a file ending
with .java.

Compiler creates
Phase 2 Compiler Disk bytecodes and stores
them on disk in a file
ending with .class.
Primary
Memory
Phase 3 Class Loader Class loader
reads .class files
containing
bytecodes from disk
and puts those
bytecodes in
Disk memory.
. ..
..
.

Primary
Memory
Phase 4 Bytecode Verifier Bytecode verifier
confirms that all
bytecodes are
valid and do not
violate Java’s
security
. ..
.. restrictions.
.

Primary
Memory Interpreter reads
Phase 5 Interpreter bytecodes and
translates them into a
language that the
computer can
understand, possibly
storing data values as
the program executes.
. ..
..
.
JAVA ENVIRONMENT
Development tools-part of java development kit
(JDK).
Classes and methods-part of Java Standard Library
(JSL), also known as Application Programming
Interface (API).
1. JDK:
Appletviewer ( for viewing applets)
Javac (Compiler)
Java (Interpreter)
Javap (Java disassembler)
Javadoc ( for creating HTML description)
Jdb (Java Debugger), etc
JAVA ENVIRONMENT
2. Application Package Interface (API)
Contains hundreds of classes and methods grouped into
several functional packages:
Language Support Package
Utility Packages
Input/Output Packages
Networking Packages
AWT Package
Applet Package
THE EVOLUTION OF JAVA
1. Java 1.0
2. Java 1.1 (Add new library, redefine applet handling and
reconfigured many features.)
3. Java 2 (Second generation). Version no:1.2 (Internal
version number of java library). Also known as J2SE
[ Java 2 Platform Standard Edition].
- Add swing, the collection framework, enhanced JVM etc.
4. J2SE 1.3
5. J2SE 1.4
6. J2SE 1.5 (J2SE5)
7. J2SE 1.6 (Java SE 6)
8. Java SE 7 (library version 1.7)
VERSIONS OF JAVA
Three versions of the Java Platform, targeted at different uses
Java Platform Micro Edition (Java ME)
Very small Java environment for smart phones, personal digital
assistant (PDA), etc
Subset of the standard Java libraries aimed at limited size and
processing power
Java Platform Standard Edition (Java SE)
The basic platform
Java SE can be used to develop client-side standalone applications or
applets.
Java Platform Enterprise Edition (Java EE)
For business applications, web services, mission-critical systems
Transaction processing, databases, distribution, replication

You might also like