Unit I Object Oriented Programming Structure
Unit I Object Oriented Programming Structure
Unit I Object Oriented Programming Structure
Object
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
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.
11
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
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).
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
Interpreted
It is interpreted language. Actually Java gets all advantages of Interpreter, without suffering from major disadvantages.
16
Source Code
Compiler
Executable File
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
Source Code
Java Compiler
Java Bytecode
19
Java bytecode
Executable File
20
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
23
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); } }
25