Unit I Object Oriented Programming Structure

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

UNIT I Object Oriented Programming Structure

Object

Concepts of Object Oriented Programming


OOPS stands for Object Oriented Programming Structure. Object Oriented Programming develops a program around its data and sets well-defined interface to that data. An object-oriented program can be characterized as data controlling access to code.

CONCEPTS OF OOPS
Objects Classes Encapsulation Data Abstraction Inheritance Polymorphism

Objects

Objects is the run time entities in an object oriented system. An objects may represent the city, name,person etc.

Object=Data+Method

Classes A class describes a group of objects with similar attributes, operations and relationship to other objects

Class

object

object

object

Employee

Emp name

Emp age

Emp salary

Encapsulation

Encapsulation is the mechanism that binds together code and the data it manipulates , and keeps both safe from outside interference and misuse.

Data Abstraction
The act of representing essential features including the background details or explanations. without

Classes use the concept of abstraction and defined as a list of attributes, and functions to operate these attributes. Its also known as Abstract DataTypes(ADT)

Inheritance
Inheritance is class acquires The concept of the the process properties by which objects of one objects of another class. the idea of

of

inheritance

provides

reusability.

Animal

Mammal

Reptile

Dog

Cat
8

Polymorphism
Polymorphism is a feature that allows one interface to be used for a general class of actions or one interface, multiple methods

Shape Draw () Box object Draw(box) Triangle object Draw(triangle)


9

Circle object Draw(circle)

Benefits of OOP

Software reusability
Code sharing Rapid prototyping Information hiding

10

Java History
Java was developed by Sun Microsystems in 1991. It is a team work comprising of James Gosling, Patrick Naughton, Chris Warth, Ed Frank and Mike Sheridan.

Initial Name was OAK.


First 02 version named as JKD 1.0 & JKD 1.1

11

Tables Illustrates the Various Versions Released


Version Release Date Major Additions

JKD 1.0
JKD 1.1 J2SE 1.2 J2SE 1.3 J2SE 1.4

January 1996
February 1997 December 1998 May 2000 February 2002

Initial Release
Inner classes, JavaBeans, JDBC, RMI Swing & Collections Framework HotSpot JVM, RMI, Javasound Regular expressions, Java Web Start

J2SE 5.0
Java SE 6

September 2004
December 2006

Generics, auto boxing, enumeration


Data Base Manager and Many new Facilities
12

Why is Java Popular for the Internet?


Main reason why Java is popular over the Internet is

that Java offers applets. browser.

Applets are tiny java programs which runs inside the Applets are very safe as they cant write to local disk. Java also supports graphical User Interface (GUI).

Moreover Java is a complete programming language.

13

Features of Java
Simple
Absence of Pointers Overloading operators are removed

Portable
Write Once Run Anywhere (WORA)

Robust
Java is robust language as it does not damage computer hardware.

14

Architectural Neutral
Independent of any microprocessor family and any particular architecture.

Distributed
Java has many inbuilt facilities which make it easy to use language in distributed system.

Secure
No Pointers Byte code verifiers Class loader Security manager
15

Object oriented Multi-threading


Ability of program to run multiple (more than one) pieces of program code simultaneously.

Interpreted
It is interpreted language. Actually Java gets all advantages of Interpreter, without suffering from major disadvantages.

16

How Java Program Runs

Source Code

Compiler

Executable File

Figure 1: Compilation of Other Language

17

To understand how Java programs to run we should under stand two new terms:

Byte Code
This code is actually platform independent. It is consider as a machine code for a hypothetical machine.

Virtual Machine
It is just a program which simulates a machine on which Java programs are supposed to run. It runs programs in byte code.

18

How Java Program Compile

Source Code

Java Compiler

Java Bytecode

Figure 2: Compilation in Java

19

How Java Program Runs

Java bytecode

Computer running Java Virtual Machine

Executable File

Figure 3: Running a Java Program

20

Advantages of Java Technology


Get Started Quickly

Write less Code


Write Better Code

Develop Programs Faster


Avoid platform dependencies with 100% pure Java

Write Once Run Anywhere


Distribute Software more Easily
21

Java Platform
A Language for writing platform A set of APIs Class Libraries Other programs used in developing, computing and error checking A VM which loads and executes the class files.

22

Development Tools
Tools Descriptions

javac
java javadoc Appletviewer jar jdb extcheck

The Compiler for the Java Programming Language


The launcher for Java applications. API Documentation Generator Run & Debug applets without web browser Manage Java Archive (JAR) Files Java Debugger Utility to detect JAR conflicts

23

Java Program Structure


Program Code
// first.java Class first {
public static void main (String args[])

Explanation
This is comment The name of the class is first. This program must be in a file first.java Left brace: Start of Class
The execution of program starts with method main ()

{
int r; r= 5; System.out.println (3.14 * r* r); } }

Left brace: start of main method


Declaration of variable r Initialization of r Program statement. Print the value Right brace :end of the method main Right brace : end of class first
24

Frequently Asked Questions


Explain Write Once and Run Anywhere nature of Java. Write Short Note on Java Virtual Machine. Describes the various features of Java. What are the advantages that IDE provides to a programmer?

25

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy