Sie sind auf Seite 1von 36

BITS Pilani

BITS Pilani
Hyderabad Campus

Dr.Aruna Malapati Asst Professor Department of CSIS

BITS Pilani
Hyderabad Campus

OBJECT ORIENTED PROGRAMMING (CSF 213)

Todays Agenda
Course Logistics Course Motivation Course Outline Basics components of computers

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Course Logistics
Instructor-in-charge Dr.Aruna Malapati (Email: arunam@bits-hyderabad.ac.in) Instructors Mrs.Kavitha Mr. M.Sadasiva Rao

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Course Logistics
Evaluations
Test 1, 20% Comprehensi ve, 35% Test 2, 20% Weekly lab evaluations, 10%

Online test , 15%

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

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Course Logistics
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)

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Text Books

T1

R1

R2

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Course Structure - Overview


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

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Why Java?

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.

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java, Web, and Beyond


Java can be used to develop Web applications. Java Applets Java Web Applications Java can also be used to develop applications for handheld devices such as Palm and cell phones

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Javas History
James Gosling and Sun Microsystems

Oak
Java, May 20, 1995, Sun World HotJava
The first Java-enabled Web browser

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java

Java is partially modeled on C++, but greatly Java Is Simple simplified and improved. Some people refer Java Is Object-Oriented to Java as "C++--" because it is like C++ but with more functionality and fewer negative Java Is Distributed aspects. 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

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java

Java is partially modeled on C++, but greatly Java Is Simple simplified and improved. Some people refer Java Is Object-Oriented to Java as "C++--" because it is like C++ but with more functionality and fewer negative Java Is Distributed aspects. 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

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java
Java Is Simple Java is inherently object-oriented. Although Java Is Object-Oriented many object-oriented languages began strictly Java Is Distributed as procedural languages, Java was designed from the start to be object-oriented. ObjectJava Is Interpreted oriented programming (OOP) is a popular Java Is Robust programming approach that is replacing Java Is Secure traditional procedural programming techniques. Java Is Architecture-Neutral Java Is Portable One of the central issues in software Java's Performance development is how to reuse code. ObjectJava Is Multithreaded oriented programming provides great flexibility, modularity, clarity, and reusability Java Is Dynamic
through encapsulation, polymorphism. inheritance, and

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java
Java Is Simple Distributed computing involves several Java Is Object-Oriented computers working together on a network. Java Is Distributed Java is designed to make distributed computing easy. Since networking capability is Java Is Interpreted inherently integrated into Java, writing Java Is Robust network programs is like sending and Java Is Secure receiving data to and from a file. Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java
Java Is Simple You need an interpreter to run Java programs. Java Is Object-Oriented The programs are compiled into the Java Java Is Distributed Virtual Machine code called bytecode. The bytecode is machine-independent and can Java Is Interpreted run on any machine that has a Java Java Is Robust interpreter, which is part of the Java Virtual Java Is Secure Machine (JVM). Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java
Java Is Simple Java Programs do not crash like C or C++. Java Is Object-Oriented Java Is Distributed Java has a runtime exception-handling feature to provide programming support for Java Is Interpreted robustness. Java Is Robust Java Is Secure Memory allocation and de allocation is automatic. Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java
Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java implements several security mechanisms Java Is Robust to protect your system against harm caused Java Is Secure by stray programs. Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Characteristics of Java
Java Is Simple Java Is Object-Oriented Java Is Distributed Write once, run anywhere Java Is Interpreted With a Java Virtual Machine (JVM), you Java Is Robust can write one program that will run on Java Is Secure any platform. Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

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 Because Java is architecture neutral, Java Java Is Portable programs are portable. They can be run Java's Performance on any platform without being Java Is Multithreaded recompiled. Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

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 Javas performance Because Java is Java Is Portable architecture neutral, Java programs are Java's Performance portable. They can be run on any platform Java Is Multithreaded without being recompiled. Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

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 Multithread programming is smoothly Java Is Portable integrated in Java, whereas in other Java's Performance languages you have to call procedures Java Is Multithreaded specific to the operating system to enable multithreading. Java Is Dynamic

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

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 was designed to adapt to an evolving Java Is Portable environment. New code can be loaded on Java's Performance the fly without recompilation. There is no Java Is Multithreaded need for developers to create, and for users to install, major new software Java Is Dynamic
versions. New features can be incorporated transparently as needed.

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Differences between C++ and Java


C++ Not purely OOP Purely OOP JAVA

Use Pointers
Memory allocation done by programmer Allows unstructured Programming Automatic typecasting Operator overloading available Constructors and destructors are used

Do nto use pointers


Memory allocation is taken care by JVM Does not allows unstructured Programming Implicit but some cases done by programmer Operator overloading not allowed Only constructors are used

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

JDK Versions
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

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

JDK Editions
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.
CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

Popular Java IDEs


NetBeans Open Source by Sun

Eclipse Open Source by IBM

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java applications
Applets Stand-alone programs Network servers Network clients Embedded designs
Mobile telephones Portable Digital Assistants (PDAs) Set-top boxes Digital Signal Processing (DSP)

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java runtime environment


Runtime Class loader Hello.java Byte code Verifier

H Hello.class
Interpreter H Runtime

JIT Code generation

Hardware

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java Virtual Machine Advantages


Compiled bytecode can run without modification on any platform that has a Java Virtual Machine. Compile once, run anywhere.

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java Virtual Machine Disadvantages


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.

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java Language Features


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

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java API Features


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.
CS/IS F213 First Semester 2012-13 BITS Pilani, Hyderabad Campus

Java API Features (Contd)


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.

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Java API Features (Contd)


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

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus

Summary
Course related issues Basic components JAVA language

CS/IS F213 First Semester 2012-13

BITS Pilani, Hyderabad Campus