SlideShare a Scribd company logo
1 of 14
Internet Programming II
Yildiz Technical University 2015
Object Oriented Programming
Ömer Taşkın
OUTLINE
•Class
– Property
– Methods
– Constructor
•Package
•Inheritance
•Interface
•Method Overloading
IP II - OOP 2
Classes
IP II - OOP 3
•Basically it’s a data type
•Holds attributes (variables)
•Has behaviors (methods)
class Person {
String name;
}
class Phone{
int number;
}
Classes
IP II - OOP 4
•Methods can be void() or have return type
class Phone {
private int number;
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
Classes
IP II - OOP 5
•Constructors are initializing method for a Class
•Phone number would be settled when Phone class initialized
class Phone {
private int number;
public Phone(int number) {
this.number = number;
}
}
•Constructors cannot have any return type!
Packages
IP II - OOP 6
•Packages have directory behavior
•Provides hierarchy and grouping
package com.otaskin.domain;
class Member {
//
}
package com.otaskin.domain;
class Product {
//
}
Packages
IP II - OOP 7
•Classes can import each other by package name + class name
•Generated value is called as FQN (Fully Qualified Name)
package com.otaskin;
import com.otaskin.domain.Member;
import com.otaskin.domain.Product;
class App {
//
}
Inheritance
IP II - OOP 8
•Basically its parent / child relationship
•Child has Parent’s behaviors
•extends is the keyword of inheritance
class Phone {
protected int number;
protected void callNumber(int
number) {
// implementation of call
}
}
class DeskPhone extends Phone {
// Phone is parent class of DeskPhone
// Also means DeskPhone is a Phone
// DeskPhone has a number so
// DeskPhone has callNumber behavior
}
Inheritance
IP II - OOP 9
•UML Diagram of extended version
Inheritance
IP II - OOP 10
•Another Example
class Person {
protected String name;
}
class Student extends Person {
// Person is parent class of Student
// Also means Student is a Person
// Student has a name so
}
Interface
IP II - OOP 11
•Interface says what can do
•Does not explain about how can do
•implements is the keyword of interfaces
interface Callable {
// cannot have body
void callNumber(int number);
}
class Phone implements Callable{
// method body is defined here
void callNumber(int number) {
// …
}
}
Overloading
IP II - OOP 12
•In OOP method names can be duplicated
•has to be parameter difference(s) between overloaded methods
interface Callable {
void callNumber(int number);
void callNumber(int number[]);
}
Overloading
IP II - OOP 13
•Also constructors are overloadable
class Person{
private String name;
private int id;
public Person() {}
public Person(String name) {
this.name = name;
}
public Person(int id) {
this.id = id;
}
public Person(String name, int id) {
this.id = id;
this.name = name;
}
}
QUESTIONS
IP II - OOP 14

More Related Content

What's hot

What's hot (14)

polymorphism
polymorphismpolymorphism
polymorphism
 
Inheritance in c++theory
Inheritance in c++theoryInheritance in c++theory
Inheritance in c++theory
 
Introduction to programming languages part 1
Introduction to programming languages   part 1Introduction to programming languages   part 1
Introduction to programming languages part 1
 
Mca 108
Mca 108Mca 108
Mca 108
 
Inheritance
InheritanceInheritance
Inheritance
 
Java
JavaJava
Java
 
Inheritance
InheritanceInheritance
Inheritance
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
Course Break - C++ Language
Course Break - C++ LanguageCourse Break - C++ Language
Course Break - C++ Language
 
Inheritance
InheritanceInheritance
Inheritance
 
Lex
LexLex
Lex
 
Computer Programming as an Educational Tool in the English Classroom: a preli...
Computer Programming as an Educational Tool in the English Classroom: a preli...Computer Programming as an Educational Tool in the English Classroom: a preli...
Computer Programming as an Educational Tool in the English Classroom: a preli...
 
Single inheritance
Single inheritanceSingle inheritance
Single inheritance
 

Similar to Oop basics

Object Oriented Programming Constructors & Destructors
Object Oriented Programming  Constructors &  DestructorsObject Oriented Programming  Constructors &  Destructors
Object Oriented Programming Constructors & Destructorsanitashinde33
 
F# Eye for the C# guy - Øredev 2013
F# Eye for the C# guy - Øredev 2013F# Eye for the C# guy - Øredev 2013
F# Eye for the C# guy - Øredev 2013Phillip Trelford
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part oneBingfeng Zhao
 
Polymorphism and Virtual Functions ppt bioinformatics
Polymorphism and Virtual Functions ppt bioinformaticsPolymorphism and Virtual Functions ppt bioinformatics
Polymorphism and Virtual Functions ppt bioinformaticsPriyanshuMittal31
 
Ti1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming LinguisticsTi1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming LinguisticsEelco Visser
 
02-OOP with Java.ppt
02-OOP with Java.ppt02-OOP with Java.ppt
02-OOP with Java.pptEmanAsem4
 
Pi j2.2 classes
Pi j2.2 classesPi j2.2 classes
Pi j2.2 classesmcollison
 
2nd puc computer science chapter 8 function overloading
 2nd puc computer science chapter 8   function overloading 2nd puc computer science chapter 8   function overloading
2nd puc computer science chapter 8 function overloadingAahwini Esware gowda
 
OOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingOOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingPurvik Rana
 
CLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxCLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxJEEVANANTHAMG6
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence pptarunsingh660
 
Android Application Development (1).pptx
Android Application Development (1).pptxAndroid Application Development (1).pptx
Android Application Development (1).pptxadityakale2110
 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritancezindadili
 

Similar to Oop basics (20)

Object Oriented Programming Constructors & Destructors
Object Oriented Programming  Constructors &  DestructorsObject Oriented Programming  Constructors &  Destructors
Object Oriented Programming Constructors & Destructors
 
F# Eye for the C# guy - Øredev 2013
F# Eye for the C# guy - Øredev 2013F# Eye for the C# guy - Øredev 2013
F# Eye for the C# guy - Øredev 2013
 
CS3391 -OOP -UNIT – IV NOTES FINAL.pdf
CS3391 -OOP -UNIT – IV NOTES FINAL.pdfCS3391 -OOP -UNIT – IV NOTES FINAL.pdf
CS3391 -OOP -UNIT – IV NOTES FINAL.pdf
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part one
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 
Polymorphism and Virtual Functions ppt bioinformatics
Polymorphism and Virtual Functions ppt bioinformaticsPolymorphism and Virtual Functions ppt bioinformatics
Polymorphism and Virtual Functions ppt bioinformatics
 
Ti1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming LinguisticsTi1220 Lecture 1: Programming Linguistics
Ti1220 Lecture 1: Programming Linguistics
 
02-OOP with Java.ppt
02-OOP with Java.ppt02-OOP with Java.ppt
02-OOP with Java.ppt
 
Pi j2.2 classes
Pi j2.2 classesPi j2.2 classes
Pi j2.2 classes
 
2nd puc computer science chapter 8 function overloading
 2nd puc computer science chapter 8   function overloading 2nd puc computer science chapter 8   function overloading
2nd puc computer science chapter 8 function overloading
 
C++ basic
C++ basicC++ basic
C++ basic
 
oop.pptx
oop.pptxoop.pptx
oop.pptx
 
OOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingOOPs Concepts - Android Programming
OOPs Concepts - Android Programming
 
CLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxCLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptx
 
Oop concept
Oop conceptOop concept
Oop concept
 
Polymorphism ppt
Polymorphism pptPolymorphism ppt
Polymorphism ppt
 
Polymorphism & inheritence ppt
Polymorphism & inheritence pptPolymorphism & inheritence ppt
Polymorphism & inheritence ppt
 
Android Application Development (1).pptx
Android Application Development (1).pptxAndroid Application Development (1).pptx
Android Application Development (1).pptx
 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritance
 

More from Ömer Taşkın (9)

Unit testing and junit
Unit testing and junitUnit testing and junit
Unit testing and junit
 
GraphDB
GraphDBGraphDB
GraphDB
 
No sql and mongodb
No sql and mongodbNo sql and mongodb
No sql and mongodb
 
Dependency management
Dependency managementDependency management
Dependency management
 
Orm
OrmOrm
Orm
 
Soa
SoaSoa
Soa
 
Web Programming - Git basics
Web Programming - Git basicsWeb Programming - Git basics
Web Programming - Git basics
 
Php101
Php101Php101
Php101
 
XXLWEB
XXLWEBXXLWEB
XXLWEB
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

Oop basics

  • 1. Internet Programming II Yildiz Technical University 2015 Object Oriented Programming Ömer Taşkın
  • 2. OUTLINE •Class – Property – Methods – Constructor •Package •Inheritance •Interface •Method Overloading IP II - OOP 2
  • 3. Classes IP II - OOP 3 •Basically it’s a data type •Holds attributes (variables) •Has behaviors (methods) class Person { String name; } class Phone{ int number; }
  • 4. Classes IP II - OOP 4 •Methods can be void() or have return type class Phone { private int number; public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } }
  • 5. Classes IP II - OOP 5 •Constructors are initializing method for a Class •Phone number would be settled when Phone class initialized class Phone { private int number; public Phone(int number) { this.number = number; } } •Constructors cannot have any return type!
  • 6. Packages IP II - OOP 6 •Packages have directory behavior •Provides hierarchy and grouping package com.otaskin.domain; class Member { // } package com.otaskin.domain; class Product { // }
  • 7. Packages IP II - OOP 7 •Classes can import each other by package name + class name •Generated value is called as FQN (Fully Qualified Name) package com.otaskin; import com.otaskin.domain.Member; import com.otaskin.domain.Product; class App { // }
  • 8. Inheritance IP II - OOP 8 •Basically its parent / child relationship •Child has Parent’s behaviors •extends is the keyword of inheritance class Phone { protected int number; protected void callNumber(int number) { // implementation of call } } class DeskPhone extends Phone { // Phone is parent class of DeskPhone // Also means DeskPhone is a Phone // DeskPhone has a number so // DeskPhone has callNumber behavior }
  • 9. Inheritance IP II - OOP 9 •UML Diagram of extended version
  • 10. Inheritance IP II - OOP 10 •Another Example class Person { protected String name; } class Student extends Person { // Person is parent class of Student // Also means Student is a Person // Student has a name so }
  • 11. Interface IP II - OOP 11 •Interface says what can do •Does not explain about how can do •implements is the keyword of interfaces interface Callable { // cannot have body void callNumber(int number); } class Phone implements Callable{ // method body is defined here void callNumber(int number) { // … } }
  • 12. Overloading IP II - OOP 12 •In OOP method names can be duplicated •has to be parameter difference(s) between overloaded methods interface Callable { void callNumber(int number); void callNumber(int number[]); }
  • 13. Overloading IP II - OOP 13 •Also constructors are overloadable class Person{ private String name; private int id; public Person() {} public Person(String name) { this.name = name; } public Person(int id) { this.id = id; } public Person(String name, int id) { this.id = id; this.name = name; } }