Click here to load reader

OOP->A Bird's-eye view

Embed Size (px)

Citation preview

Introduction to OOP using Java

Saugata BoseIntroduction to OOP using Java

Different Programming Paradigms

Structured Programming

Object Oriented Programming

Java is an Object Oriented Language

ObjectsClassInheritanceEncapsulation

Example of a Java Codeclass Hello {public static void main(String[] args) {System.out.println(Hello World !!!); }}Hello.javaC:\javac Hello.java

C:\java HelloClass NameHello.class

OS/Hardwaremachine code

C source codehello.cgcchello.exe

Platform Dependent JVM

Java source codehello.javajavachello.class

OS/HardwarePlatform Independent

Objects Everywhere

NameHeightWeightEye ColormrBeanmyLamp

ColorHeight

IdentityProperties

Objects have state

Objects have behavior

Then what are objects .

How to interact with program?Service Provider

A class represents a concept, and an object represents the embodiment of a class

Objects and Classes

Bank AccountJohns Bank AccountBalance: $5,257Bills Bank AccountBalance: $1,245,069datamethods

Java Software

Person

Sakib

TamimTamimSakib: Say your nameclass Person{String askName(Person obj){System.out.println("My name is "+obj.toString());}}

class Main{public static void main(String[] args){Person shakib=new Person();Person tamim=new Person();shakib.askName(tamim);}}

Inheritance

Class Hierarchy

Generalization and Specialization

Encapsulation

Separation Why Java then?ModularityInformation Hiding class A{ int noOneCanSeeMe=5; int display(){System.out.println("Anyone can see me");}}Access Modifierspublicprivatepublic