CSF213-L1

36
BITS Pilani Hyderabad Campus BITS Pilani Dr.Aruna Malapati Asst Professor Department of CSIS

Transcript of CSF213-L1

Page 1: CSF213-L1

BITS PilaniHyderabad Campus

BITS Pilani

Dr.Aruna MalapatiAsst Professor

Department of CSIS

Page 2: CSF213-L1

BITS PilaniHyderabad Campus

OBJECT ORIENTED PROGRAMMING (CSF 213)

Page 3: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Course Logistics• Course Motivation• Course OutlineCourse Outline• Basics components of computersBasics components of computers

Today’s Agenda

Page 4: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

–Instructor-in-charge

Dr.Aruna Malapati (Email: [email protected])

–Instructors

Mrs.Kavitha

Mr. M.Sadasiva Rao

Course Logistics

Page 5: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

Course Logistics

Make-Up Policy– NO Make Up for Online test and weekly labs. – Makeup for other components is granted on prior permissions and valid

document.

Test 1, 20%

Test 2, 20%

Weekly lab evaluations,

10%Online test ,

15%

Comprehensive, 35%

Evaluations

Page 6: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Tutorials– Weekly twice as per the time table– Should attend registered section only– Focus on practical aspects of programming and complex problem solving

• Self learning requirements Class work will require students’ further exploration

• Chamber consultation hours : Monday (4.00 – 5.00 Pm)

• Course Notices:• CSIS Notice board(B-Block)

Course Logistics

Page 7: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

Text Books

T1 R1 R2

Page 8: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Introduction to JAVA and UML• Java Programming Basics• Java features• Java’s Collection Framework• Exception Handling • Object – Oriented Design Process• Design Principles• Object oriented patterns• GUI Programming

Course Structure - Overview

Page 9: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• The answer is that Java enables users to develop and deploy applications on the Internet for servers, desktop computers, and small hand-held devices. The future of computing is being profoundly influenced by the Internet, and Java promises to remain a big part of that future. Java is the Internet programming language.

Java is a general purpose programming language. Java is the Internet programming language.

Why Java?

Page 10: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Java can be used to develop Web applications.• Java Applets• Java Web Applications• Java can also be used to develop applications for hand-

held devices such as Palm and cell phones

Java, Web, and Beyond

Page 11: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• James Gosling and Sun Microsystems

• Oak

• Java, May 20, 1995, Sun World

• HotJava – The first Java-enabled Web browser

Java’s History

Page 12: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Java is partially modeled on C++, but greatly simplified and improved. Some people refer to Java as "C++--" because it is like C++ but with more functionality and fewer negative aspects.

Page 13: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Java is partially modeled on C++, but greatly simplified and improved. Some people refer to Java as "C++--" because it is like C++ but with more functionality and fewer negative aspects.

Page 14: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Java is inherently object-oriented. Although many object-oriented languages began strictly as procedural languages, Java was designed from the start to be object-oriented. Object-oriented programming (OOP) is a popular programming approach that is replacing traditional procedural programming techniques.

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 15: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Distributed computing involves several computers working together on a network. Java is designed to make distributed computing easy. Since networking capability is inherently integrated into Java, writing network programs is like sending and receiving data to and from a file.

Page 16: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

You need an interpreter to run Java programs. The programs are compiled into the Java Virtual Machine code called bytecode. The bytecode is machine-independent and can run on any machine that has a Java interpreter, which is part of the Java Virtual Machine (JVM).

Page 17: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Java Programs do not crash like C or C++.

Java has a runtime exception-handling feature to provide programming support for robustness.

Memory allocation and de allocation is automatic.

Page 18: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Java implements several security mechanisms to protect your system against harm caused by stray programs.

Page 19: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Write once, run anywhere

With a Java Virtual Machine (JVM), you can write one program that will run on any platform.

Page 20: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Because Java is architecture neutral, Java programs are portable. They can be run on any platform without being recompiled.

Page 21: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Java’s performance Because Java is architecture neutral, Java programs are portable. They can be run on any platform without being recompiled.

Page 22: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Multithread programming is smoothly integrated in Java, whereas in other languages you have to call procedures specific to the operating system to enable multithreading.

Page 23: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• 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

Characteristics of Java

Java was designed to adapt to an evolving environment. New code can be loaded on the fly without recompilation. There is no need for developers to create, and for users to install, major new software versions. New features can be incorporated transparently as needed.

Page 24: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

Differences between C++ and Java

C++ JAVA

Not purely OOP Purely OOP

Use Pointers Do nto use pointers

Memory allocation done by programmer Memory allocation is taken care by JVM

Allows unstructured Programming Does not allows unstructured Programming

Automatic typecasting Implicit but some cases done by programmer

Operator overloading available Operator overloading not allowed

Constructors and destructors are used Only constructors are used

Page 25: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• JDK 1.02 (1995)• JDK 1.1 (1996)• JDK 1.2 (1998)• JDK 1.3 (2000)• JDK 1.4 (2002)• JDK 1.5 (2004) a. k. a. JDK 5 or Java 5• JDK 1.6 (2006) a. k. a. JDK 6 or Java 6• JDK 1.7 (possibly 2010) a. k. a. JDK 7 or Java 7

JDK Versions

Page 26: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Java Standard Edition (J2SE)– J2SE can be used to develop client-side standalone applications or

applets.– Contains basic core Java classes, used to develop standard

applications and applets.

• Java Enterprise Edition (J2EE)– J2EE can be used to develop server-side applications such as Java

servlets and Java ServerPages. – Mainly provides business solutions on network

• Java Micro Edition (J2ME). – J2ME can be used to develop applications for mobile devices such

as cell phones. – Mainly used by developers for writing code on portable devices

code is small and memory is limited.

JDK Editions

Page 27: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• NetBeans Open Source by Sun

• Eclipse Open Source by IBM

Popular Java IDEs

Page 28: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Applets • Stand-alone programs• Network servers• Network clients• Embedded designs

– Mobile telephones

– Portable Digital Assistants (PDAs)

– Set-top boxes

– Digital Signal Processing (DSP)

Java applications

Page 29: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

Java runtime environment

H

Hello.java

Hello.classH

Runtime

Class loader

Byte code Verifier

Interpreter

Runtime

JIT Code generation

Hardware

Page 30: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Compiled bytecode can run without modification on any platform that has a Java Virtual Machine.

• “Compile once, run anywhere”.

Java Virtual MachineAdvantages

Page 31: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Compiled bytecode runs a little slower than conventional compiled code.

– Advances in JVM technology are closing the gap.• Not all low-level system manipulations are available

through standard Java APIs.– Low-level system manipulations are available in the form of native (non-Java)

extensions.

Java Virtual Machine Disadvantages

Page 32: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Full support for OOP– Classes and objects– Information hiding/access control– Inheritance, method overriding– Polymorphism– Abstract methods and classes– Interfaces

Java Language Features

Page 33: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Support for the essentials– Classes and objects– I/O– Threads

• Applet support– Conventions used by applets

• Graphic User Interface (GUI) support– Abstract Windowing Toolkit (AWT)

• Windows, dialogs, file dialogs• Buttons, checkboxes• Menus, menu bars• Scrollbars• etc.

– New generation GUI toolkit: Swing• All the above, plus...• Platform independent and run-time changeable look-and-feel.• And more.

Java API Features

Page 34: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Networking– TCP/IP– UDP– URLs

• Internationalization– Programs can automatically adapt to specific locales and be displayed in the

appropriate language.

• Security– Electronic signatures– Public and private key management– Access control– Certificates

• Java Database Connectivity (JDBCTM)– Provides uniform access to a wide range of relational databases.

Java API Features (Contd…)

Page 35: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

The Java platform also has APIs for – 2D and 3D graphics– Accessibility– Servers– Collaboration– Telephony– Speech– Animation– and more.

Java API Features (Contd…)

Page 36: CSF213-L1

CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

• Course related issues• Basic components JAVA language

Summary