SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Basic Object-Oriented
concepts
Scott Lee
leesungki@gmail.com
Targets for Programming
• Repetitive Job
• Complex Process
Who are players?
• Properties
• Operations
Object
• State  Properties, Attributes, Members
• Behavior  Methods, Functions
Class and Object
Example of a class
class Employee {
// fields
String name;
double salary;
// a method
void pay () {
System.out.println("Pay to the order of " +
name + " $" + salary);
}
}
Approximate Terminology
• instance = object
• field = variable
• method = function
• sending a message to an object =
calling a function
• These are all approximately true
Reuse
• Similar
• Simpler
• Consistent
Solution
• Inheritance
• Encapsulation
• Polymorphism
• Interface
Example of inheritance
class Person {
String name;
String age;
void birthday () {
age = age + 1;
}
}
class Employee
extends Person {
double salary;
void pay () { ...}
}
Every Employee has a name, age, and birthday
method as well as a salary and a pay method.
Example of Encapsulation
class Person {
private String name;
private String age;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
} …
}
Example of Polymorphism
class Employee extends Person {
private String address;
public String mailCheck() {
return “checking “ + name + address”;
} …
}
nt number; public Employee(String name, String address, int number) { System.out.println("Constructing an Employee"); this.name = name; this.address = address; this.number = nu
Example of Polymorphism
class SalaryEmployee extends Employee {
private String salary;
public String mailCheck() {
return “checking “ + name + salary”;
} …
}
Example of Polymorphism
public class VirtualDemo {
public static void main(String [] args) {
SalaryEmployee s = new SalaryEmployee("Mohd Mohtashim", "Ambehta,
UP", 3, 3600.00);
Employee e = new Salary("John Adams", "Boston, MA", 2, 2400.00);
System.out.println("Call mailCheck using Salary reference --");
s.mailCheck();
System.out.println("n Call mailCheck using Employee reference--");
e.mailCheck(); }
}
Call mailCheck using Salary reference – 3600
Call mailCheck using Employee reference – Boston, MA
Example of Interface
interface Animal {
public void eat();
public void travel();
}
public class MammalInt implements Animal {
public void eat() {
System.out.println("Mammal eats");
}
public void travel(){
System.out.println("Mammal travels");
}
public int noOfLegs(){
return 0;
}
public static void main(String args[]){
MammalInt m = new MammalInt();
m.eat();
m.travel();
}
}
Concept: Constructors make objects
• Every class has a constructor to make its objects
• Use the keyword new to call a constructor
secretary = new Employee ( );
• You can write your own constructors; but if you don’t,
• Java provides a default constructor with no arguments
– It sets all the fields of the new object to zero
– If this is good enough, you don’t need to write your own
• The syntax for writing constructors is almost like that
for writing methods
Syntax for constructors
• Instead of a return type and a name, just use
the class name
• You can supply arguments
Employee (String theName, double theSalary) {
name = theName;
salary = theSalary;
}
Example of a class variable
class Person {
String name;
int age;
static int population;
Person (String name) {
this.name = name;
this.age = 0;
population++;
}
}
The End

Weitere ähnliche Inhalte

Was ist angesagt?

Json and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and SlickJson and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and SlickStephen Kemmerling
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreNicolas Carlo
 
Protocols
ProtocolsProtocols
ProtocolsSV.CO
 
C++ programming structure & union
C++ programming structure & unionC++ programming structure & union
C++ programming structure & unionargusacademy
 
Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwoEishay Smith
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkMooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkJose Luis Martínez
 
David Grudl: Novinky v Nette
David Grudl: Novinky v NetteDavid Grudl: Novinky v Nette
David Grudl: Novinky v NetteDevelcz
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)Christopher Roach
 
Python programming Part -6
Python programming Part -6Python programming Part -6
Python programming Part -6Megha V
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional ProgrammingDmitry Buzdin
 
Rxjava2 custom operator
Rxjava2 custom operatorRxjava2 custom operator
Rxjava2 custom operator彥彬 洪
 
Scala Quick Introduction
Scala Quick IntroductionScala Quick Introduction
Scala Quick IntroductionDamian Jureczko
 
The underestimated power of KeyPaths
The underestimated power of KeyPathsThe underestimated power of KeyPaths
The underestimated power of KeyPathsVincent Pradeilles
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Jesper Kamstrup Linnet
 
Giving Clarity to LINQ Queries by Extending Expressions R2
Giving Clarity to LINQ Queries by Extending Expressions R2Giving Clarity to LINQ Queries by Extending Expressions R2
Giving Clarity to LINQ Queries by Extending Expressions R2Ed Charbeneau
 

Was ist angesagt? (20)

Json and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and SlickJson and SQL DB serialization Introduction with Play! and Slick
Json and SQL DB serialization Introduction with Play! and Slick
 
From OOP To FP Through A Practical Case
From OOP To FP Through A Practical CaseFrom OOP To FP Through A Practical Case
From OOP To FP Through A Practical Case
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscore
 
Map, Reduce and Filter in Swift
Map, Reduce and Filter in SwiftMap, Reduce and Filter in Swift
Map, Reduce and Filter in Swift
 
Using Java Streams
Using Java StreamsUsing Java Streams
Using Java Streams
 
Protocols
ProtocolsProtocols
Protocols
 
C++ programming structure & union
C++ programming structure & unionC++ programming structure & union
C++ programming structure & union
 
Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwo
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkMooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
 
David Grudl: Novinky v Nette
David Grudl: Novinky v NetteDavid Grudl: Novinky v Nette
David Grudl: Novinky v Nette
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)
 
Python programming Part -6
Python programming Part -6Python programming Part -6
Python programming Part -6
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Rxjava2 custom operator
Rxjava2 custom operatorRxjava2 custom operator
Rxjava2 custom operator
 
Scala Quick Introduction
Scala Quick IntroductionScala Quick Introduction
Scala Quick Introduction
 
The underestimated power of KeyPaths
The underestimated power of KeyPathsThe underestimated power of KeyPaths
The underestimated power of KeyPaths
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
Linq
LinqLinq
Linq
 
Giving Clarity to LINQ Queries by Extending Expressions R2
Giving Clarity to LINQ Queries by Extending Expressions R2Giving Clarity to LINQ Queries by Extending Expressions R2
Giving Clarity to LINQ Queries by Extending Expressions R2
 

Andere mochten auch

The Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - EmmaThe Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - Emmaregacylady
 
XING Q3 report 2012 english version
XING Q3 report 2012 english versionXING Q3 report 2012 english version
XING Q3 report 2012 english versionXING SE
 
Las Vegas - July 2008, Travel Digest
Las Vegas - July 2008, Travel DigestLas Vegas - July 2008, Travel Digest
Las Vegas - July 2008, Travel DigestSarah Wrightson
 
01 introduction E-Commerce
01 introduction E-Commerce01 introduction E-Commerce
01 introduction E-CommerceNirbhay Singh
 
kls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakatkls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakatNovii Kanadia
 
Linus Torvalds Just For Fun
Linus Torvalds Just For FunLinus Torvalds Just For Fun
Linus Torvalds Just For Funpps_ps
 
Why scala - executive overview
Why scala - executive overviewWhy scala - executive overview
Why scala - executive overviewRazvan Cojocaru
 
цахим монгол
цахим монголцахим монгол
цахим монголod_tsetsegmaa
 
What color do you like
What color do you likeWhat color do you like
What color do you likeorncn
 
Hadoop Robot from eBay at China Hadoop Summit 2015
Hadoop Robot from eBay at China Hadoop Summit 2015Hadoop Robot from eBay at China Hadoop Summit 2015
Hadoop Robot from eBay at China Hadoop Summit 2015polo li
 
Baiguullaga organition 2012
Baiguullaga organition 2012Baiguullaga organition 2012
Baiguullaga organition 2012oyundariubuns
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programsrashmi322
 
Budget Simulation Assignment Renee Jackson
Budget Simulation Assignment Renee JacksonBudget Simulation Assignment Renee Jackson
Budget Simulation Assignment Renee Jacksonrjackstar
 
Mot tinh yeu dung nghia
Mot tinh yeu dung nghiaMot tinh yeu dung nghia
Mot tinh yeu dung nghiapeprocy
 
Dispositivos de entrada
Dispositivos de entradaDispositivos de entrada
Dispositivos de entradapatiluki
 
Đề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh Hóa
Đề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh HóaĐề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh Hóa
Đề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh Hóaschoolantoreecom
 
The new masters of management
The new masters of managementThe new masters of management
The new masters of managementrsoosaar
 

Andere mochten auch (20)

Makalah dematitis
Makalah dematitisMakalah dematitis
Makalah dematitis
 
The Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - EmmaThe Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - Emma
 
XING Q3 report 2012 english version
XING Q3 report 2012 english versionXING Q3 report 2012 english version
XING Q3 report 2012 english version
 
Las Vegas - July 2008, Travel Digest
Las Vegas - July 2008, Travel DigestLas Vegas - July 2008, Travel Digest
Las Vegas - July 2008, Travel Digest
 
01 introduction E-Commerce
01 introduction E-Commerce01 introduction E-Commerce
01 introduction E-Commerce
 
kls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakatkls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakat
 
Linus Torvalds Just For Fun
Linus Torvalds Just For FunLinus Torvalds Just For Fun
Linus Torvalds Just For Fun
 
Why scala - executive overview
Why scala - executive overviewWhy scala - executive overview
Why scala - executive overview
 
aplication gogogo
aplication gogogoaplication gogogo
aplication gogogo
 
цахим монгол
цахим монголцахим монгол
цахим монгол
 
What color do you like
What color do you likeWhat color do you like
What color do you like
 
Hadoop Robot from eBay at China Hadoop Summit 2015
Hadoop Robot from eBay at China Hadoop Summit 2015Hadoop Robot from eBay at China Hadoop Summit 2015
Hadoop Robot from eBay at China Hadoop Summit 2015
 
Baiguullaga organition 2012
Baiguullaga organition 2012Baiguullaga organition 2012
Baiguullaga organition 2012
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programs
 
Budget Simulation Assignment Renee Jackson
Budget Simulation Assignment Renee JacksonBudget Simulation Assignment Renee Jackson
Budget Simulation Assignment Renee Jackson
 
Mot tinh yeu dung nghia
Mot tinh yeu dung nghiaMot tinh yeu dung nghia
Mot tinh yeu dung nghia
 
Dispositivos de entrada
Dispositivos de entradaDispositivos de entrada
Dispositivos de entrada
 
Đề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh Hóa
Đề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh HóaĐề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh Hóa
Đề thi thử Đại học lần 1 năm 2016 THPT Bỉm Sơn Thanh Hóa
 
Building Comfort with MATLAB
Building Comfort with MATLABBuilding Comfort with MATLAB
Building Comfort with MATLAB
 
The new masters of management
The new masters of managementThe new masters of management
The new masters of management
 

Ähnlich wie Basic Object Oriented Concepts

define a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdfdefine a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdffashioncollection2
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdffatoryoutlets
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesNebojša Vukšić
 
Assignment 7
Assignment 7Assignment 7
Assignment 7IIUM
 
Java Polymorphism Part 2
Java Polymorphism Part 2Java Polymorphism Part 2
Java Polymorphism Part 2AathikaJava
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionKent Huang
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfforwardcom41
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfShashikantSathe3
 
Type script by Howard
Type script by HowardType script by Howard
Type script by HowardLearningTech
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116Paulo Morgado
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by HowardLearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type scriptLearningTech
 
Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in javaHarish Gyanani
 

Ähnlich wie Basic Object Oriented Concepts (20)

define a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdfdefine a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdf
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examples
 
java script
java scriptjava script
java script
 
Core C#
Core C#Core C#
Core C#
 
Assignment 7
Assignment 7Assignment 7
Assignment 7
 
Prototype Framework
Prototype FrameworkPrototype Framework
Prototype Framework
 
Java Polymorphism Part 2
Java Polymorphism Part 2Java Polymorphism Part 2
Java Polymorphism Part 2
 
Java 8 revealed
Java 8 revealedJava 8 revealed
Java 8 revealed
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 Function
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
 
Week 12 code
Week 12 codeWeek 12 code
Week 12 code
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
 
Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in java
 

Mehr von Scott Lee

Angular 4 Introduction Tutorial
Angular 4 Introduction TutorialAngular 4 Introduction Tutorial
Angular 4 Introduction TutorialScott Lee
 
Mean full stack development
Mean full stack developmentMean full stack development
Mean full stack developmentScott Lee
 
Angular JS, steal the idea
Angular JS, steal the ideaAngular JS, steal the idea
Angular JS, steal the ideaScott Lee
 
Resilience 위기관리능력, 캐나다행 토크쇼
Resilience 위기관리능력, 캐나다행 토크쇼Resilience 위기관리능력, 캐나다행 토크쇼
Resilience 위기관리능력, 캐나다행 토크쇼Scott Lee
 
Serendipity, 행운을 가져오는 능력, 캐나다 취업유학
Serendipity, 행운을 가져오는 능력, 캐나다 취업유학Serendipity, 행운을 가져오는 능력, 캐나다 취업유학
Serendipity, 행운을 가져오는 능력, 캐나다 취업유학Scott Lee
 
캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011
캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011
캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011Scott Lee
 
Canada education marketing in korea
Canada education marketing in koreaCanada education marketing in korea
Canada education marketing in koreaScott Lee
 

Mehr von Scott Lee (7)

Angular 4 Introduction Tutorial
Angular 4 Introduction TutorialAngular 4 Introduction Tutorial
Angular 4 Introduction Tutorial
 
Mean full stack development
Mean full stack developmentMean full stack development
Mean full stack development
 
Angular JS, steal the idea
Angular JS, steal the ideaAngular JS, steal the idea
Angular JS, steal the idea
 
Resilience 위기관리능력, 캐나다행 토크쇼
Resilience 위기관리능력, 캐나다행 토크쇼Resilience 위기관리능력, 캐나다행 토크쇼
Resilience 위기관리능력, 캐나다행 토크쇼
 
Serendipity, 행운을 가져오는 능력, 캐나다 취업유학
Serendipity, 행운을 가져오는 능력, 캐나다 취업유학Serendipity, 행운을 가져오는 능력, 캐나다 취업유학
Serendipity, 행운을 가져오는 능력, 캐나다 취업유학
 
캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011
캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011
캐나다유학을 통해서 취업하는 방법 - 캐나다교육박람회 2011
 
Canada education marketing in korea
Canada education marketing in koreaCanada education marketing in korea
Canada education marketing in korea
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 

Kürzlich hochgeladen (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

Basic Object Oriented Concepts

  • 2. Targets for Programming • Repetitive Job • Complex Process
  • 3. Who are players? • Properties • Operations
  • 4. Object • State  Properties, Attributes, Members • Behavior  Methods, Functions
  • 6. Example of a class class Employee { // fields String name; double salary; // a method void pay () { System.out.println("Pay to the order of " + name + " $" + salary); } }
  • 7. Approximate Terminology • instance = object • field = variable • method = function • sending a message to an object = calling a function • These are all approximately true
  • 10. Example of inheritance class Person { String name; String age; void birthday () { age = age + 1; } } class Employee extends Person { double salary; void pay () { ...} } Every Employee has a name, age, and birthday method as well as a salary and a pay method.
  • 11. Example of Encapsulation class Person { private String name; private String age; public void setName(String name) { this.name = name; } public String getName() { return name; } … }
  • 12. Example of Polymorphism class Employee extends Person { private String address; public String mailCheck() { return “checking “ + name + address”; } … } nt number; public Employee(String name, String address, int number) { System.out.println("Constructing an Employee"); this.name = name; this.address = address; this.number = nu
  • 13. Example of Polymorphism class SalaryEmployee extends Employee { private String salary; public String mailCheck() { return “checking “ + name + salary”; } … }
  • 14. Example of Polymorphism public class VirtualDemo { public static void main(String [] args) { SalaryEmployee s = new SalaryEmployee("Mohd Mohtashim", "Ambehta, UP", 3, 3600.00); Employee e = new Salary("John Adams", "Boston, MA", 2, 2400.00); System.out.println("Call mailCheck using Salary reference --"); s.mailCheck(); System.out.println("n Call mailCheck using Employee reference--"); e.mailCheck(); } } Call mailCheck using Salary reference – 3600 Call mailCheck using Employee reference – Boston, MA
  • 15. Example of Interface interface Animal { public void eat(); public void travel(); } public class MammalInt implements Animal { public void eat() { System.out.println("Mammal eats"); } public void travel(){ System.out.println("Mammal travels"); } public int noOfLegs(){ return 0; } public static void main(String args[]){ MammalInt m = new MammalInt(); m.eat(); m.travel(); } }
  • 16. Concept: Constructors make objects • Every class has a constructor to make its objects • Use the keyword new to call a constructor secretary = new Employee ( ); • You can write your own constructors; but if you don’t, • Java provides a default constructor with no arguments – It sets all the fields of the new object to zero – If this is good enough, you don’t need to write your own • The syntax for writing constructors is almost like that for writing methods
  • 17. Syntax for constructors • Instead of a return type and a name, just use the class name • You can supply arguments Employee (String theName, double theSalary) { name = theName; salary = theSalary; }
  • 18. Example of a class variable class Person { String name; int age; static int population; Person (String name) { this.name = name; this.age = 0; population++; } }