19
Object Oriented Concepts With JAVA Mehta Ishani 2 nd M.E.(C.S.E)

Object oriented concepts with java

Embed Size (px)

DESCRIPTION

Object oriented concepts with java

Citation preview

Page 1: Object oriented concepts with java

Object Oriented Concepts With JAVA

Mehta Ishani2nd M.E.(C.S.E)

Page 2: Object oriented concepts with java

Why OOP?

• Traditional Procedural-Oriented languages– difficult to copy a function from one program and

reuse in another program because the the function is reference the headers, global variables and other functions.(i.e. not well-encapsulated as a self-contained reusable unit.)

– not suitable of high-level abstraction for solving real life problems.

Page 3: Object oriented concepts with java

Why OOP?

• Object-oriented programming (OOP) languages– class, which encapsulates both the static

attributes and dynamic behaviors (i.e. well-encapsulated, easier to reuse)

– permit higher level of abstraction for solving real-life problems

Page 4: Object oriented concepts with java

Benefits of OOP

• Ease in software design

• Ease in software maintenance

• Reusable software

Page 5: Object oriented concepts with java

What is JAVA?

• programming language expressly designed for use in the distributed environment of the Internet

• Simple, Secure, Robust, Complete Object Oriented and Platform Independent High level Language.

• It is portable and Multi-thread technology gives High performance.

Page 6: Object oriented concepts with java

JAVA

Hardware Platform

Java Platform

Software (OS) Platform

Operates and Controls H/W

Environment for Java

Development

JVM API

Page 7: Object oriented concepts with java

JAVA

How it Works:

Page 8: Object oriented concepts with java

JAVA

Java Program

Virtual Machine

Source code Bytecode

Java Compiler

Process of Compilation:

Java Interpreter

Virtual Machine

Real Machine

Bytecode

Page 9: Object oriented concepts with java

Object

• real word entity that has state and behavior• contains data (instance variables)

representing its state, and instance methods, which are the things it can do.

• instance of a class

Page 10: Object oriented concepts with java

Class

• Collection of objects• template, blueprint or contract that defines

what an object’s data fields and methods will be.

Page 11: Object oriented concepts with java

Abstraction

• Hiding internal details and showing functionality

• In java, we use abstract class and interface to achieve abstraction.

Page 12: Object oriented concepts with java

Encapsulation

• Binding (or wrapping) code and data together into a single unit

• A java class • Java bean

Page 13: Object oriented concepts with java

Inheritance

• When one object acquires all the properties and behaviors of parent object

• provides code reusability. • Used to achieve runtime polymorphism.

Page 14: Object oriented concepts with java

Inheritance

A

B

C

A B

CA-1

A-2

B-1

B-2

AB

Multi-level Inheritance Multiple Inheritance

Multiple Multi-level Inheritance

Types of Inheritance:

Page 15: Object oriented concepts with java

Ploymorphism

• "Poly" means "many" and "morph" means "form".

• When one task is performed by different ways

Page 16: Object oriented concepts with java

Polymorphism

• same word or symbol to be interpreted correctly in different situations based on the context

• There are two types of polymorphism :1.Compile-time polymorphism (Method Overloading/Static)2.Runtime Polymorphism (Method Overriding/Dynamic)

Page 17: Object oriented concepts with java

Ploymorphism

Method Overloading:having multiple methods with same name but

with different signature (number, type and order of parameters).

Method Overriding:When a subclass contains a method with the same

name and signature as in the super class then it is called as method overriding.

Page 18: Object oriented concepts with java

Summery

• An object is an instance of a class.• Using abstraction one can simulate real world objects.• Abstraction provides advantage of code reuse• Abstraction enables program open for extension• Encapsulation provides the security that keeps data and

methods safe from inadvertent changes.• Inheritance is parent-child relationship of class which is

mainly used for code reusability.• Polymorphism definition is that Poly means many and

morphos means forms.

Page 19: Object oriented concepts with java

Questions??????