lec 2 30_jul13

18

Click here to load reader

Upload: palak-sanghani

Post on 06-May-2015

435 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Lec 2 30_jul13

Introduction to Java

Lecture 2

Naveen Kumar

Page 2: Lec 2 30_jul13

Why OOP?

Modularization Decompose problem into smaller

subproblems that can be solved separately.

2

Page 3: Lec 2 30_jul13

Why OOP?

Abstraction -- Understandability

Individual modules are understandable by human readers.

3

Page 4: Lec 2 30_jul13

Why OOP?

Encapsulation -- Information Hiding

Hide complexity from the user of a software. Protect low-level functionality.

4

Page 5: Lec 2 30_jul13

Why OOP?

Composability -- Structured Design

Interfaces allow to freely combine modules to produce new systems.

5

Page 6: Lec 2 30_jul13

Why OOP?

Hierarchy

Incremental development from small and simple to more complex modules.

6

Complexityincreases

Page 7: Lec 2 30_jul13

Why OOP?

Continuity

Changes and maintenance in only a few modules does not affect the architecture.

7

Page 8: Lec 2 30_jul13

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

Page 9: Lec 2 30_jul13

Why Java ?

Java is a general purpose object oriented programming language

Internet programming language

9

Page 10: Lec 2 30_jul13

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

Page 11: Lec 2 30_jul13

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)

Page 12: Lec 2 30_jul13

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

Page 13: Lec 2 30_jul13

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

Page 14: Lec 2 30_jul13

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

Page 15: Lec 2 30_jul13

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

Page 16: Lec 2 30_jul13

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.

Page 17: Lec 2 30_jul13

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

Page 18: Lec 2 30_jul13

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