SlideShare a Scribd company logo
Object	
  Orientated	
  Programming	
  with	
  
                   Java	
  
               Jussi	
  Pohjolainen	
  
   Tampere	
  University	
  of	
  Applied	
  Sciences	
  
Object	
  Orientated	
  Concepts
                                           	
  
•    Class	
  
•    Object	
  
•    Inheritance	
  
•    Constructors	
  
•    Abstract	
  class	
  
•    Interface	
  
•    Polymorphism	
  
Class
                                            	
  
class Student {
   private String name;
   public Student(String name) {
      this.name = name;
   }
   public void setName(String name) {
      this.name = name
   }
   public void getName() {
      return name;
   }
}
CreaAng	
  objects
                                 	
  
Student jack = new Student(“Jack”);
Student bill = new Student(“Bill”);
System.out.println( jack.getName() );
System.out.println( bill.getName() );
Reference?	
  
Student jack = new Student(“Jack”);
Student bill = jack;
jack.setName(“Lisa”);
// What is the output?
System.out.println(bill.getName());
Reference	
  
•  In	
  Java,	
  every	
  object	
  is	
  passed	
  by	
  reference	
  
•  If	
  you	
  want	
  to	
  clone	
  a	
  object,	
  you	
  use	
  special	
  
   techniques	
  (later	
  on	
  the	
  material)	
  
Inheritance	
  
class Person {
   private String name;
  ...
}

class Student extends Person {
   private int id;
   ...
}
Constructors
                                        	
  
class Person {
   private String name;
   public Person() {
     System.out.println(“Person”);
   }
}
class Student extends Person {
   private int id;
   public Student() {
     System.out.println(“Student”);
   }
}
// What is the output?
Student s = new Student();
Default	
  Constructor
                                       	
  
•  If	
  programmer	
  does	
  not	
  define	
  a	
  constructor,	
  Java	
  
   creates	
  a	
  default	
  constructor:	
  
    class Person {
    }
    =>
    class Person {
       public Person() {
         super();
       }
    }
Default	
  Constructor
                                      	
  
class Person {
   private String name;
   public Person() {
    System.out.println(“Person”);
   }
}
class Student extends Person {
   private int id;
}
// What is the output?
Student s = new Student();
Default	
  Constructor	
  Problem	
  
class Person {
   private String name;
   public Person(String name) {
    System.out.println(“Person”);
   }
}
class Student extends Person {
   private int id;
}
// What is the output?
Student s = new Student();
Abstract	
  Class
                                         	
  
•  You	
  cannot	
  create	
  a	
  object	
  from	
  abstract	
  class	
  
•  Abstract	
  class	
  may	
  contain	
  abstract	
  method	
  
•  Abstract	
  method	
  is	
  a	
  method	
  declaraAon	
  which	
  
   must	
  be	
  implemented	
  in	
  inherited	
  classes	
  
Abstract	
  Class
                                      	
  
abstract class Graphic {
   abstract double calculateSurfaceArea();
}
class Circle extends Graphic {
   private int radius;
   double calculateSurfaceArea() {
    ...
   }
}
Abstract	
  Class
                                      	
  
abstract class A {
   abstract void m();
}
abstract class B extends A {
   // What is the implementation of the class B?
}
Interface	
  
•  Interface	
  is	
  a	
  abstract	
  class	
  that	
  contain	
  only	
  
   abstract	
  methods	
  
•  Interface	
  can	
  contain	
  also	
  public	
  staAc	
  final	
  
   variables	
  
•  Class	
  can	
  inherit	
  only	
  one	
  class,	
  but	
  it	
  can	
  
   implement	
  many	
  interfaces	
  
Interface	
  
interface class A {
   public void m();
}

class B implements A {
   public void m() {
    ...
   }
}
Polymorphism	
  
•  Declaring	
  a	
  object:	
  
     –  Graphic c;!
•  IniAalizing	
  the	
  object:	
  
     –  c = new Graphic();!
•  This	
  is	
  also	
  possible:	
  
     –  c = new Circle();!
     –  c = new Rect();!
•  If	
  Circle and	
  Rect are	
  inherited	
  from	
  Graphic!
Polymorphism	
  
class Polymorphism {
   public static void main(String [] args) {
    // What are the possible objects to be passed?
    method(??)
   }
   public static void method(Graphic c) {
    ...
   }
}
Polymorphism	
  
interface R {
   ...
}
class Polymorphism {
   public static void main(String [] args) {
    // What are the possible objects to be passed?
    method(??)
   }
   public static void method(R r) {
    ...
   }
}
Cloning	
  
class Person implements Cloneable {
   private name;
   public Person(String name) {
    this.name = name;
   }
   public Object clone() {
    return new Person(this.name);
   }
}
Person a = new Person(“jack”);
Person b = a.clone();
Equals
                                 	
  
// What happens here?
Student jack1 = new Student(“Jack”);
Student jack2 = new Student(“Jack”);
System.out.println( jack1 == jack2 ); // true or false?
System.out.println( jack1.equals(jack2) ); // ?

More Related Content

What's hot

ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
Atul Sehdev
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
mcollison
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Best Core Java Training In Bangalore
Best Core Java Training In BangaloreBest Core Java Training In Bangalore
Best Core Java Training In Bangalore
rajkamaltibacademy
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3
Mahmoud Alfarra
 
Core java
Core javaCore java
Core java
Rajkattamuri
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
Fajar Baskoro
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Class or Object
Class or ObjectClass or Object
Class or Object
Rahul Bathri
 
Object and class
Object and classObject and class
Object and class
mohit tripathi
 
Classes and objects in java
Classes and objects in javaClasses and objects in java
Classes and objects in java
Muthukumaran Subramanian
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Javabackdoor
 
Classes&objects
Classes&objectsClasses&objects
Classes&objects
M Vishnuvardhan Reddy
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
Fajar Baskoro
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with JavaJussi Pohjolainen
 
[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing
Muhammad Hammad Waseem
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
mcollison
 
Java OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - InheritanceJava OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - Inheritance
OUM SAOKOSAL
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
OUM SAOKOSAL
 

What's hot (20)

ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Best Core Java Training In Bangalore
Best Core Java Training In BangaloreBest Core Java Training In Bangalore
Best Core Java Training In Bangalore
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Core java
Core javaCore java
Core java
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Class or Object
Class or ObjectClass or Object
Class or Object
 
Object and class
Object and classObject and class
Object and class
 
Classes and objects in java
Classes and objects in javaClasses and objects in java
Classes and objects in java
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
Classes&objects
Classes&objectsClasses&objects
Classes&objects
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
 
Java OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - InheritanceJava OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - Inheritance
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
 

Viewers also liked

Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
Julie Iskander
 
Applying OO Concepts
Applying OO ConceptsApplying OO Concepts
Applying OO Concepts
Mohammed Irfan Shaikh
 
JavaYDL15
JavaYDL15JavaYDL15
JavaYDL15
Terry Yoast
 
Itt1 sd uml and oo
Itt1 sd uml and ooItt1 sd uml and oo
Itt1 sd uml and oo
Morten Nielsen
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_javaSelf
 
Introduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereIntroduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphere
eLink Business Innovations
 
Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)
Hirra Sultan
 
OOP programming
OOP programmingOOP programming
OOP programminganhdbh
 
OO Development 3 - Models And UML
OO Development 3 - Models And UMLOO Development 3 - Models And UML
OO Development 3 - Models And UML
Randy Connolly
 
Module 3 Object Oriented Data Models Object Oriented notations
Module 3  Object Oriented Data Models Object Oriented notationsModule 3  Object Oriented Data Models Object Oriented notations
Module 3 Object Oriented Data Models Object Oriented notations
Taher Barodawala
 
Packaes & interfaces
Packaes & interfacesPackaes & interfaces
Packaes & interfaces
yugandhar vadlamudi
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
Colin Riley
 
Uml
UmlUml
Uml
parag
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
agorolabs
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12koolkampus
 
Objects & OO Thinking for Java
Objects & OO Thinking for JavaObjects & OO Thinking for Java
Objects & OO Thinking for Java
Jeff Sonstein
 

Viewers also liked (17)

Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
Applying OO Concepts
Applying OO ConceptsApplying OO Concepts
Applying OO Concepts
 
JavaYDL15
JavaYDL15JavaYDL15
JavaYDL15
 
Itt1 sd uml and oo
Itt1 sd uml and ooItt1 sd uml and oo
Itt1 sd uml and oo
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_java
 
OO & UML
OO & UMLOO & UML
OO & UML
 
Introduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereIntroduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphere
 
Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)
 
OOP programming
OOP programmingOOP programming
OOP programming
 
OO Development 3 - Models And UML
OO Development 3 - Models And UMLOO Development 3 - Models And UML
OO Development 3 - Models And UML
 
Module 3 Object Oriented Data Models Object Oriented notations
Module 3  Object Oriented Data Models Object Oriented notationsModule 3  Object Oriented Data Models Object Oriented notations
Module 3 Object Oriented Data Models Object Oriented notations
 
Packaes & interfaces
Packaes & interfacesPackaes & interfaces
Packaes & interfaces
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
 
Uml
UmlUml
Uml
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
 
Objects & OO Thinking for Java
Objects & OO Thinking for JavaObjects & OO Thinking for Java
Objects & OO Thinking for Java
 

Similar to Java OO Revisited

Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
Jamie (Taka) Wang
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
AbdulImrankhan7
 
Core Java
Core JavaCore Java
Core Java
Khasim Saheb
 
Core java concepts
Core java concepts Core java concepts
Core java concepts
javeed_mhd
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
Karthik Rohan
 
11slide.ppt
11slide.ppt11slide.ppt
11slide.ppt
MohammedNouh7
 
Java Methods
Java MethodsJava Methods
Java Methods
Rosmina Joy Cabauatan
 
11slide
11slide11slide
11slide
IIUM
 
OOPs & Inheritance Notes
OOPs & Inheritance NotesOOPs & Inheritance Notes
OOPs & Inheritance Notes
Shalabh Chaudhary
 
Corejava Training in Bangalore Tutorial
Corejava Training in Bangalore TutorialCorejava Training in Bangalore Tutorial
Corejava Training in Bangalore Tutorial
rajkamaltibacademy
 
C h 04 oop_inheritance
C h 04 oop_inheritanceC h 04 oop_inheritance
C h 04 oop_inheritanceshatha00
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdf
irshadkumar3
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
Danairat Thanabodithammachari
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
ArafatSahinAfridi
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
BG Java EE Course
 
Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)
OUM SAOKOSAL
 
Sonu wiziq
Sonu wiziqSonu wiziq
Sonu wiziq
Sonu WIZIQ
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Concepts
mdfkhan625
 

Similar to Java OO Revisited (20)

Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
 
Core Java
Core JavaCore Java
Core Java
 
Core java concepts
Core java concepts Core java concepts
Core java concepts
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
11slide.ppt
11slide.ppt11slide.ppt
11slide.ppt
 
Java Methods
Java MethodsJava Methods
Java Methods
 
11slide
11slide11slide
11slide
 
OOPs & Inheritance Notes
OOPs & Inheritance NotesOOPs & Inheritance Notes
OOPs & Inheritance Notes
 
Corejava Training in Bangalore Tutorial
Corejava Training in Bangalore TutorialCorejava Training in Bangalore Tutorial
Corejava Training in Bangalore Tutorial
 
C h 04 oop_inheritance
C h 04 oop_inheritanceC h 04 oop_inheritance
C h 04 oop_inheritance
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdf
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
8 polymorphism
8 polymorphism8 polymorphism
8 polymorphism
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
 
Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)
 
Sonu wiziq
Sonu wiziqSonu wiziq
Sonu wiziq
 
core java
core javacore java
core java
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Concepts
 

More from Jussi Pohjolainen

Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
Jussi Pohjolainen
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
Jussi Pohjolainen
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
Jussi Pohjolainen
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
Jussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
Jussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
Jussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript DevelopmentJussi Pohjolainen
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
Jussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
Jussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
Jussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platformJussi Pohjolainen
 

More from Jussi Pohjolainen (20)

Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 

Java OO Revisited

  • 1. Object  Orientated  Programming  with   Java   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  • 2. Object  Orientated  Concepts   •  Class   •  Object   •  Inheritance   •  Constructors   •  Abstract  class   •  Interface   •  Polymorphism  
  • 3. Class   class Student { private String name; public Student(String name) { this.name = name; } public void setName(String name) { this.name = name } public void getName() { return name; } }
  • 4. CreaAng  objects   Student jack = new Student(“Jack”); Student bill = new Student(“Bill”); System.out.println( jack.getName() ); System.out.println( bill.getName() );
  • 5. Reference?   Student jack = new Student(“Jack”); Student bill = jack; jack.setName(“Lisa”); // What is the output? System.out.println(bill.getName());
  • 6. Reference   •  In  Java,  every  object  is  passed  by  reference   •  If  you  want  to  clone  a  object,  you  use  special   techniques  (later  on  the  material)  
  • 7. Inheritance   class Person { private String name; ... } class Student extends Person { private int id; ... }
  • 8. Constructors   class Person { private String name; public Person() { System.out.println(“Person”); } } class Student extends Person { private int id; public Student() { System.out.println(“Student”); } } // What is the output? Student s = new Student();
  • 9. Default  Constructor   •  If  programmer  does  not  define  a  constructor,  Java   creates  a  default  constructor:   class Person { } => class Person { public Person() { super(); } }
  • 10. Default  Constructor   class Person { private String name; public Person() { System.out.println(“Person”); } } class Student extends Person { private int id; } // What is the output? Student s = new Student();
  • 11. Default  Constructor  Problem   class Person { private String name; public Person(String name) { System.out.println(“Person”); } } class Student extends Person { private int id; } // What is the output? Student s = new Student();
  • 12. Abstract  Class   •  You  cannot  create  a  object  from  abstract  class   •  Abstract  class  may  contain  abstract  method   •  Abstract  method  is  a  method  declaraAon  which   must  be  implemented  in  inherited  classes  
  • 13. Abstract  Class   abstract class Graphic { abstract double calculateSurfaceArea(); } class Circle extends Graphic { private int radius; double calculateSurfaceArea() { ... } }
  • 14. Abstract  Class   abstract class A { abstract void m(); } abstract class B extends A { // What is the implementation of the class B? }
  • 15. Interface   •  Interface  is  a  abstract  class  that  contain  only   abstract  methods   •  Interface  can  contain  also  public  staAc  final   variables   •  Class  can  inherit  only  one  class,  but  it  can   implement  many  interfaces  
  • 16. Interface   interface class A { public void m(); } class B implements A { public void m() { ... } }
  • 17. Polymorphism   •  Declaring  a  object:   –  Graphic c;! •  IniAalizing  the  object:   –  c = new Graphic();! •  This  is  also  possible:   –  c = new Circle();! –  c = new Rect();! •  If  Circle and  Rect are  inherited  from  Graphic!
  • 18. Polymorphism   class Polymorphism { public static void main(String [] args) { // What are the possible objects to be passed? method(??) } public static void method(Graphic c) { ... } }
  • 19. Polymorphism   interface R { ... } class Polymorphism { public static void main(String [] args) { // What are the possible objects to be passed? method(??) } public static void method(R r) { ... } }
  • 20. Cloning   class Person implements Cloneable { private name; public Person(String name) { this.name = name; } public Object clone() { return new Person(this.name); } } Person a = new Person(“jack”); Person b = a.clone();
  • 21. Equals   // What happens here? Student jack1 = new Student(“Jack”); Student jack2 = new Student(“Jack”); System.out.println( jack1 == jack2 ); // true or false? System.out.println( jack1.equals(jack2) ); // ?