lec 2 30_jul13
TRANSCRIPT
Introduction to Java
Lecture 2
Naveen Kumar
Why OOP?
Modularization Decompose problem into smaller
subproblems that can be solved separately.
2
Why OOP?
Abstraction -- Understandability
Individual modules are understandable by human readers.
3
Why OOP?
Encapsulation -- Information Hiding
Hide complexity from the user of a software. Protect low-level functionality.
4
Why OOP?
Composability -- Structured Design
Interfaces allow to freely combine modules to produce new systems.
5
Why OOP?
Hierarchy
Incremental development from small and simple to more complex modules.
6
Complexityincreases
Why OOP?
Continuity
Changes and maintenance in only a few modules does not affect the architecture.
7
Main OOP Language Features
Classes: Modularization, structure. Inheritance / extends: Hierarchy of modules,
incremental development. Public / Protected / Private: Encapsulation. Interfaces / Abstract Classes: Composability. Polymorphism / virtual: Hierarchy of modules,
incremental development. Templates: Type independent abstract data
types. 8
Why Java ?
Java is a general purpose object oriented programming language
Internet programming language
9
Java Book’s
1. Big Java (3rd Edition)Author : Cay Horstmann
2. The complete reference of java 2 (J2SE 6 Edition)Author : Herbert Schieldt
3. Programming in Java2Author : E. Balagurusamy
Web Source: http://java.sun.com/docs/books/tutorial/ http://java.sun.com/javase/6/docs
History of Java
A general purpose OOP 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)
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
representationByte Code:-A highly optimized set of instructions to be executed by the
java runtime system, known as java virtual machine (JVM)-Not executable codeJVM:- Need to be implemented for each platform- Although the details vary from machine to machine, all JVM
understand the same byte code
Java compiler produces an intermediate code known as byte code for a machine, known as JVM
It exists only inside the computer memory
Machine code is generated by the java interpreter by acting as an intermediary between the virtual machine and real machine
Java Virtual Machine
Java Program Java Compiler Bytecode
Bytecode Java Interpreter Machine Code
JVM
Characteristics of Java
Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic
14 www.cs.armstrong.edu/liang/intro6e/JavaCharacteristics.pdf
Characteristics of Java
Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic
15
Java is partially modeled on C++, but greatly simplified and improved. It is like C++ but with more functionality and fewer negative aspects
Characteristics of Java
Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic
16
Java is inherently object-oriented. Java was designed from the start to be object-oriented.
One of the central issues in software development is how to reuse code. Object-oriented programming provides great flexibility, modularity, clarity, and reusability through encapsulation, inheritance, and polymorphism.
Characteristics of Java
Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic
17
Distributed computing involves several computers working together on a network.
Java is designed to make distributed computing (e.g. Web Services) easy. Since networking capability is inherently integrated into Java, writing network programs is like sending and receiving data to and from a file
Characteristics of Java
Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic
18
You need an interpreter to run Java programs.
The programs are compiled into bytecode. The bytecode is machine-independent and can run on any machine that has a Java interpreter, which is part of the JVM