SlideShare a Scribd company logo
Module 04 – Object Oriented in Java
Danairat T.
Line ID: Danairat
FB: Danairat Thanabodithammachari
+668-1559-1446
Fundamental Java Programming
The Course Outline
Module 01 – Introduction to Java
Module 02 – Basic Java Programming
Module 03 – Control Flow and Exception Handling
Module 04 – Object Oriented in Java
Module 05 – Java Package and Access Control
Module 06 – Java File IO
Module 07 – Java Networking
Module 08 – Java Threading
Module 04 – Object Oriented in Java
• Java Class
• Java Object
• Java Variable
• Java Method and Constructor
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Java Class
A class is a blueprint or prototype from which objects are
created. This section defines a class that models the state
and behavior of a real-world object. It intentionally focuses on
the basics, showing how even a simple class can cleanly
model state and behavior.
Java Object
Java Object is conceptually similar to real-world objects.
They consist of state and behavior.
An object stores its state in fields (variables) and exposes its
behavior through methods.
Methods operate on an object's internal state. Hiding internal
state is known as data encapsulation
Class
Object 1
Object 2
Blueprint
Instance
Java Class Syntax
["public"] ["abstract"|"final"]"class" Class_name
["extends" object_name] ["implements"
interface_name]
"{"
// properties declarations
// behavior declarations
"}"
Class Members
Class consists from two main members:-
• Variable
• Method
Variable
Member variables in a class—these are called fields.
- Class – static member
- Object – instance member
Variables in a method or block of code—these are called local variables.
Variables in method declarations—these are called parameters.
Method
[ "public" | "private" | "protected" ] [ "final" ]
[ "static" | "abstract" ]
return_data_type method_name "(" parameter_list ")"
"{"
// some defining actions
"}"
public static void example1() {}
public static int add2(int x) {x+=2; return x;}
public static double example3(int x, double d) {return x*d;}
public static void example4(int x, int y, boolean flag) {}
public static void example5(int arr[]) {} // note: this is object
Type of Java Method
1. Constructor methods
These allow class objects to be created with fields initialized to values
as determined by the methods' parameters. This allows objects to start
with values appropriate to use
public Box() {length=0;width=0;height=0;} // default is point public Box(int l,int w,int h) // allows
giving initial size {length=l; width=w; height=h;}
2. Accessor (or observer) methods read property (ie. field variable) values
and are conventionally named getField() or whatever the property is
called.
3. Mutator (or transformer) methods set property values and are often
named setField() etc. Mutators can be used to ensure that the
property's value is valid in both range and type.
4. Helper methods support modular of code structure in a unit of working.
Overloading Method
The Java programming language supports overloading methods,
and Java can distinguish between methods with different method
signatures (Method Name, Argument Type, Number of Argument).
public class TouchPointer {
...
public void draw(int i) {
...
}
public void draw(double f) {
...
}
public void draw(int i, int j) {
...
}
}
Constructor
When you create a new instance (a new object) of a class using the new
keyword, a constructor for that class is called. Constructors are used to
initialize the instance variables (fields) of an object. Constructors are
similar to methods, but with some important differences.
• Constructor name is class name. Eg. YourClassName() {}
• Default constructor. If you don't define a constructor for a class, a
default parameterless constructor is automatically created by the
compiler. The default constructor calls the default parent constructor
(super()) and initializes all instance variables to default value.
• Default constructor is created only if there are no constructors. If you
define any constructor for your class, no default constructor is
automatically created.
Differences between methods and
constructors
1. There is no return type given in a constructor signature
(header). The value is this object itself so there is no need
to indicate a return value.
2. There is no return statement in the body of the constructor.
3. The first line of a constructor must either be a call on
another constructor in the same class (using this), or a call
on the superclass constructor (using super). If the first line
is neither of these, the compiler automatically inserts a call
to the parameterless super class constructor.
LAB – ConstructTest1
public class ConstructTest {
int value1;
int value2;
ConstructTest() {
value1 = 10;
value2 = 20;
System.out.println("Inside Constructor");
}
public void display() {
System.out.println("Value1 === " + value1);
System.out.println("Value2 === " + value2);
}
public static void main(String[] args) {
ConstructTest c1 = new ConstructTest();
c1.display();
}
}
Inside Constructor
Value1 === 10
Value2 === 20
Creating Object HereCreating
Reference
Activating Method
LAB - Constructor Overloading
class ConstrutOverloadDemo {
int value1;
int value2;
ConstrutOverloadDemo() {
value1 = 10;
value2 = 20;
System.out.println("Inside 1st Constructor");
}
ConstrutOverloadDemo(int a) {
value1 = a;
System.out.println("Inside 2nd Constructor");
}
ConstrutOverloadDemo(int a, int b) {
value1 = a;
value2 = b;
System.out.println("Inside 3rd Constructor");
}
public void display() {
System.out.println("Value1 === " + value1);
System.out.println("Value2 === " + value2);
}
public static void main(String[] args) {
ConstrutOverloadDemo c1 = new
ConstrutOverloadDemo();
ConstrutOverloadDemo c2 = new
ConstrutOverloadDemo(30);
ConstrutOverloadDemo c3 = new
ConstrutOverloadDemo(30, 40);
c1.display();
c2.display();
c3.display();
}
}
LAB - Constructor Chain
class ConstrucChainDemo{
int value1;
int value2;
ConstrucChainDemo(){
value1 = 1;
value2 = 2;
System.out.println("Inside 1st Parent Constructor");
}
ConstrucChainDemo(int a, int b){
value1 = a;
value2 = b;
Syastem.out.println("Inside 2nd Parent Constructor");
}
}
class ConstrucChild extends ConstrucChainDemo{
int value3;
int value4;
ConstrucChild(){
super(11,22);
value3 = 3;
value4 = 4;
System.out.println("Inside the Constructor of Child");
}
public void display(){
System.out.println("Value1 === "+value1);
System.out.println("Value2 === "+value2);
System.out.println("Value3 === "+value3);
System.out.println("Value4 === "+value4);
}
}
public static void main(String args[]){
ConstrucChild c1 = new ConstrucChild();
c1.display();
}
Object Oriented History
The sense of object-oriented programming term seems to
make their first appearance at MIT in the late 1950s
Object-oriented programming is modeled on how in the
real world objects are made up of many kinds of smaller
objects.
The Smalltalk language, which was developed at Xerox
PARC (by Alan Kay and others) in the 1970s, introduced
the term object-oriented programming to represent the
pervasive use of objects and messages as the basis for
computation.
Abstraction
Abstraction(hiding implementation) focuses on the
outside view of an object.. (i.e. the interface)
Abstraction is an essential element for OO which
manages the complexity. In a sense when someone
works on a computer not necessary that he should
know the working of each and every part of the
computer.
interface Customer {
void printCustomer (int i);
}
Encapsulation
Encapsulation (hiding information) prevents clients from
seeing its inside view, where the behavior of the
abstraction is implemented
It is the mechanism that binds together state and behavior
in manipulates and keeps both safe from outside
interference and misuse.
class Customer {
private String name;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
Inheritance
It is the process by which one object acquires the properties
of another object. This supports the hierarchical
classification. Without the use of hierarchies each object
would need to define all its characteristics explicitly.
However by use of inheritance, an object need only define
those qualities that make it unique within its class.
Java use “extend” keyword to inherit properties and
behavior from super to its sub class.
class Customer {
String name;
public String getName() {
}
}
class MemberCustomer extends
Customer {
int collectedPoints;
}
Polymorphism
The ability of the object design to group object behavior
from different types.
So by using this, one object can be treated like another
even it came from difference hierarchy.
The programmers can focus on selected behavior by no
need to know the exact type of object in advance and this
is being implemented at runtime.
Defining the Behavior
public interface IFace_Printable {
public void printNow();
}
Defining Classes which are the same
behavior
public class CustomerInfo implements IFace_Printable{
@Override
public void printNow() {
System.out.println("Read Customer Table... CustomerInfo. Done.");
}
}
public class ProductInfo implements IFace_Printable{
@Override
public void printNow() {
System.out.println("Reading Product Table... ProductInfo. Done.");
}
}
Create Polymorphic Method
public class PrintServer {
private IFace_Printable iFacePrintable;
PrintServer(IFace_Printable iFacePrintable){
this.iFacePrintable = iFacePrintable;
}
public void printNowWraper(){
iFacePrintable.printNow();
}
}
Create Test Client for the Polymorphic Method
public class PrintClientApplication {
private static CustomerInfo customerInfo = new CustomerInfo();
private static ProductInfo productInfo = new ProductInfo();
public static void main(String [] args) {
new PrintServer(customerInfo).printNowWraper();
new PrintServer(productInfo).printNowWraper();
}
}
Danairat T.
Line ID: Danairat
FB: Danairat Thanabodithammachari
+668-1559-1446
Thank you

More Related Content

What's hot (20)

OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Sagar Verma
 
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Sagar Verma
 
Class introduction in java
Class introduction in javaClass introduction in java
Class introduction in java
yugandhar vadlamudi
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
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
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
backdoor
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
DevaKumari Vijay
 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Sagar Verma
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Sagar Verma
 
Lecture - 5 Control Statement
Lecture - 5 Control StatementLecture - 5 Control Statement
Lecture - 5 Control Statement
manish kumar
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
SRM Institute of Science & Technology, Tiruchirappalli
 
OOPs & Inheritance Notes
OOPs & Inheritance NotesOOPs & Inheritance Notes
OOPs & Inheritance Notes
Shalabh Chaudhary
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
Shalabh Chaudhary
 
core java
core javacore java
core java
Vinodh Kumar
 
Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part I
Eduardo Bergavera
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
manish kumar
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
Basic java for Android Developer
Basic java for Android DeveloperBasic java for Android Developer
Basic java for Android Developer
Nattapong Tonprasert
 
Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of java
kamal kotecha
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Sagar Verma
 
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Sagar Verma
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
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
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
backdoor
 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Sagar Verma
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Sagar Verma
 
Lecture - 5 Control Statement
Lecture - 5 Control StatementLecture - 5 Control Statement
Lecture - 5 Control Statement
manish kumar
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part I
Eduardo Bergavera
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
manish kumar
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of java
kamal kotecha
 

Viewers also liked (8)

Chapter 4 Powerpoint
Chapter 4 PowerpointChapter 4 Powerpoint
Chapter 4 Powerpoint
Gus Sandoval
 
Introduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging APIIntroduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging API
white paper
 
C0 review core java1
C0 review core java1C0 review core java1
C0 review core java1
tam53pm1
 
Eo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5eEo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5e
Gina Bullock
 
Java basic
Java basicJava basic
Java basic
Arati Gadgil
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
Danairat Thanabodithammachari
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
yugandhar vadlamudi
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
Danairat Thanabodithammachari
 
Chapter 4 Powerpoint
Chapter 4 PowerpointChapter 4 Powerpoint
Chapter 4 Powerpoint
Gus Sandoval
 
Introduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging APIIntroduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging API
white paper
 
C0 review core java1
C0 review core java1C0 review core java1
C0 review core java1
tam53pm1
 
Eo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5eEo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5e
Gina Bullock
 
Ad

Similar to Java Programming - 04 object oriented in java (20)

Oop java
Oop javaOop java
Oop java
Minal Maniar
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
Khaled Anaqwa
 
Java PPT OOPS prepared by Abhinav J.pptx
Java PPT OOPS prepared by Abhinav J.pptxJava PPT OOPS prepared by Abhinav J.pptx
Java PPT OOPS prepared by Abhinav J.pptx
JainSaab2
 
Class and Object.pptx from nit patna ece department
Class and Object.pptx from nit patna ece departmentClass and Object.pptx from nit patna ece department
Class and Object.pptx from nit patna ece department
om2348023vats
 
Class and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdfClass and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
 
Java basics
Java basicsJava basics
Java basics
Shivanshu Purwar
 
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTORUNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
JAVA Class Presentation.pdf Vsjsjsnheheh
JAVA Class Presentation.pdf VsjsjsnhehehJAVA Class Presentation.pdf Vsjsjsnheheh
JAVA Class Presentation.pdf Vsjsjsnheheh
AnushreeP4
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptx
NitishChaulagai
 
javaopps concepts
javaopps conceptsjavaopps concepts
javaopps concepts
Nikhil Agrawal
 
UNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptxUNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
Introduction to OOPs second year cse.pptx
Introduction to OOPs second year cse.pptxIntroduction to OOPs second year cse.pptx
Introduction to OOPs second year cse.pptx
solemanhldr
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
AnmolVerma363503
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
Ahmad sohail Kakar
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
ilias ahmed
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
introduction to object oriented programming language java
introduction to object oriented programming language javaintroduction to object oriented programming language java
introduction to object oriented programming language java
RitikGarg39
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
chetanpatilcp783
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
Khaled Anaqwa
 
Java PPT OOPS prepared by Abhinav J.pptx
Java PPT OOPS prepared by Abhinav J.pptxJava PPT OOPS prepared by Abhinav J.pptx
Java PPT OOPS prepared by Abhinav J.pptx
JainSaab2
 
Class and Object.pptx from nit patna ece department
Class and Object.pptx from nit patna ece departmentClass and Object.pptx from nit patna ece department
Class and Object.pptx from nit patna ece department
om2348023vats
 
Class and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdfClass and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
 
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTORUNIT I 	OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
JAVA Class Presentation.pdf Vsjsjsnheheh
JAVA Class Presentation.pdf VsjsjsnhehehJAVA Class Presentation.pdf Vsjsjsnheheh
JAVA Class Presentation.pdf Vsjsjsnheheh
AnushreeP4
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptx
NitishChaulagai
 
UNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptxUNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
Introduction to OOPs second year cse.pptx
Introduction to OOPs second year cse.pptxIntroduction to OOPs second year cse.pptx
Introduction to OOPs second year cse.pptx
solemanhldr
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
ilias ahmed
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
introduction to object oriented programming language java
introduction to object oriented programming language javaintroduction to object oriented programming language java
introduction to object oriented programming language java
RitikGarg39
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
chetanpatilcp783
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
Ad

More from Danairat Thanabodithammachari (20)

Thailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AMThailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AM
Danairat Thanabodithammachari
 
Agile Management
Agile ManagementAgile Management
Agile Management
Danairat Thanabodithammachari
 
Agile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 DanairatAgile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 Danairat
Danairat Thanabodithammachari
 
Blockchain for Management
Blockchain for ManagementBlockchain for Management
Blockchain for Management
Danairat Thanabodithammachari
 
Enterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 DanairatEnterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 Danairat
Danairat Thanabodithammachari
 
Agile Enterprise Architecture - Danairat
Agile Enterprise Architecture - DanairatAgile Enterprise Architecture - Danairat
Agile Enterprise Architecture - Danairat
Danairat Thanabodithammachari
 
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by DanairatDigital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Danairat Thanabodithammachari
 
Big data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guideBig data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guide
Danairat Thanabodithammachari
 
Big data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guideBig data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guide
Danairat Thanabodithammachari
 
Perl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File ProcessingPerl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File Processing
Danairat Thanabodithammachari
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
Danairat Thanabodithammachari
 
Perl Programming - 03 Programming File
Perl Programming - 03 Programming FilePerl Programming - 03 Programming File
Perl Programming - 03 Programming File
Danairat Thanabodithammachari
 
Perl Programming - 02 Regular Expression
Perl Programming - 02 Regular ExpressionPerl Programming - 02 Regular Expression
Perl Programming - 02 Regular Expression
Danairat Thanabodithammachari
 
Perl Programming - 01 Basic Perl
Perl Programming - 01 Basic PerlPerl Programming - 01 Basic Perl
Perl Programming - 01 Basic Perl
Danairat Thanabodithammachari
 
Setting up Hadoop YARN Clustering
Setting up Hadoop YARN ClusteringSetting up Hadoop YARN Clustering
Setting up Hadoop YARN Clustering
Danairat Thanabodithammachari
 
JEE Programming - 03 Model View Controller
JEE Programming - 03 Model View ControllerJEE Programming - 03 Model View Controller
JEE Programming - 03 Model View Controller
Danairat Thanabodithammachari
 
JEE Programming - 05 JSP
JEE Programming - 05 JSPJEE Programming - 05 JSP
JEE Programming - 05 JSP
Danairat Thanabodithammachari
 
JEE Programming - 04 Java Servlets
JEE Programming - 04 Java ServletsJEE Programming - 04 Java Servlets
JEE Programming - 04 Java Servlets
Danairat Thanabodithammachari
 
JEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application DeploymentJEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application Deployment
Danairat Thanabodithammachari
 
JEE Programming - 07 EJB Programming
JEE Programming - 07 EJB ProgrammingJEE Programming - 07 EJB Programming
JEE Programming - 07 EJB Programming
Danairat Thanabodithammachari
 
Thailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AMThailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AM
Danairat Thanabodithammachari
 
Agile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 DanairatAgile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 Danairat
Danairat Thanabodithammachari
 
Enterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 DanairatEnterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 Danairat
Danairat Thanabodithammachari
 
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by DanairatDigital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Danairat Thanabodithammachari
 
Big data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guideBig data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guide
Danairat Thanabodithammachari
 
Big data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guideBig data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guide
Danairat Thanabodithammachari
 
Perl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File ProcessingPerl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File Processing
Danairat Thanabodithammachari
 
JEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application DeploymentJEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application Deployment
Danairat Thanabodithammachari
 

Recently uploaded (20)

How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Essentials of Resource Planning in a Downturn
Essentials of Resource Planning in a DownturnEssentials of Resource Planning in a Downturn
Essentials of Resource Planning in a Downturn
OnePlan Solutions
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
iOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod KumariOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod Kumar
Pramod Kumar
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
SheenBrisals
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Essentials of Resource Planning in a Downturn
Essentials of Resource Planning in a DownturnEssentials of Resource Planning in a Downturn
Essentials of Resource Planning in a Downturn
OnePlan Solutions
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
iOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod KumariOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod Kumar
Pramod Kumar
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
Eliminate the complexities of Event-Driven Architecture with Domain-Driven De...
SheenBrisals
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 

Java Programming - 04 object oriented in java

  • 1. Module 04 – Object Oriented in Java Danairat T. Line ID: Danairat FB: Danairat Thanabodithammachari +668-1559-1446
  • 2. Fundamental Java Programming The Course Outline Module 01 – Introduction to Java Module 02 – Basic Java Programming Module 03 – Control Flow and Exception Handling Module 04 – Object Oriented in Java Module 05 – Java Package and Access Control Module 06 – Java File IO Module 07 – Java Networking Module 08 – Java Threading
  • 3. Module 04 – Object Oriented in Java • Java Class • Java Object • Java Variable • Java Method and Constructor • Abstraction • Encapsulation • Inheritance • Polymorphism
  • 4. Java Class A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.
  • 5. Java Object Java Object is conceptually similar to real-world objects. They consist of state and behavior. An object stores its state in fields (variables) and exposes its behavior through methods. Methods operate on an object's internal state. Hiding internal state is known as data encapsulation Class Object 1 Object 2 Blueprint Instance
  • 6. Java Class Syntax ["public"] ["abstract"|"final"]"class" Class_name ["extends" object_name] ["implements" interface_name] "{" // properties declarations // behavior declarations "}"
  • 7. Class Members Class consists from two main members:- • Variable • Method Variable Member variables in a class—these are called fields. - Class – static member - Object – instance member Variables in a method or block of code—these are called local variables. Variables in method declarations—these are called parameters.
  • 8. Method [ "public" | "private" | "protected" ] [ "final" ] [ "static" | "abstract" ] return_data_type method_name "(" parameter_list ")" "{" // some defining actions "}" public static void example1() {} public static int add2(int x) {x+=2; return x;} public static double example3(int x, double d) {return x*d;} public static void example4(int x, int y, boolean flag) {} public static void example5(int arr[]) {} // note: this is object
  • 9. Type of Java Method 1. Constructor methods These allow class objects to be created with fields initialized to values as determined by the methods' parameters. This allows objects to start with values appropriate to use public Box() {length=0;width=0;height=0;} // default is point public Box(int l,int w,int h) // allows giving initial size {length=l; width=w; height=h;} 2. Accessor (or observer) methods read property (ie. field variable) values and are conventionally named getField() or whatever the property is called. 3. Mutator (or transformer) methods set property values and are often named setField() etc. Mutators can be used to ensure that the property's value is valid in both range and type. 4. Helper methods support modular of code structure in a unit of working.
  • 10. Overloading Method The Java programming language supports overloading methods, and Java can distinguish between methods with different method signatures (Method Name, Argument Type, Number of Argument). public class TouchPointer { ... public void draw(int i) { ... } public void draw(double f) { ... } public void draw(int i, int j) { ... } }
  • 11. Constructor When you create a new instance (a new object) of a class using the new keyword, a constructor for that class is called. Constructors are used to initialize the instance variables (fields) of an object. Constructors are similar to methods, but with some important differences. • Constructor name is class name. Eg. YourClassName() {} • Default constructor. If you don't define a constructor for a class, a default parameterless constructor is automatically created by the compiler. The default constructor calls the default parent constructor (super()) and initializes all instance variables to default value. • Default constructor is created only if there are no constructors. If you define any constructor for your class, no default constructor is automatically created.
  • 12. Differences between methods and constructors 1. There is no return type given in a constructor signature (header). The value is this object itself so there is no need to indicate a return value. 2. There is no return statement in the body of the constructor. 3. The first line of a constructor must either be a call on another constructor in the same class (using this), or a call on the superclass constructor (using super). If the first line is neither of these, the compiler automatically inserts a call to the parameterless super class constructor.
  • 13. LAB – ConstructTest1 public class ConstructTest { int value1; int value2; ConstructTest() { value1 = 10; value2 = 20; System.out.println("Inside Constructor"); } public void display() { System.out.println("Value1 === " + value1); System.out.println("Value2 === " + value2); } public static void main(String[] args) { ConstructTest c1 = new ConstructTest(); c1.display(); } } Inside Constructor Value1 === 10 Value2 === 20 Creating Object HereCreating Reference Activating Method
  • 14. LAB - Constructor Overloading class ConstrutOverloadDemo { int value1; int value2; ConstrutOverloadDemo() { value1 = 10; value2 = 20; System.out.println("Inside 1st Constructor"); } ConstrutOverloadDemo(int a) { value1 = a; System.out.println("Inside 2nd Constructor"); } ConstrutOverloadDemo(int a, int b) { value1 = a; value2 = b; System.out.println("Inside 3rd Constructor"); } public void display() { System.out.println("Value1 === " + value1); System.out.println("Value2 === " + value2); } public static void main(String[] args) { ConstrutOverloadDemo c1 = new ConstrutOverloadDemo(); ConstrutOverloadDemo c2 = new ConstrutOverloadDemo(30); ConstrutOverloadDemo c3 = new ConstrutOverloadDemo(30, 40); c1.display(); c2.display(); c3.display(); } }
  • 15. LAB - Constructor Chain class ConstrucChainDemo{ int value1; int value2; ConstrucChainDemo(){ value1 = 1; value2 = 2; System.out.println("Inside 1st Parent Constructor"); } ConstrucChainDemo(int a, int b){ value1 = a; value2 = b; Syastem.out.println("Inside 2nd Parent Constructor"); } } class ConstrucChild extends ConstrucChainDemo{ int value3; int value4; ConstrucChild(){ super(11,22); value3 = 3; value4 = 4; System.out.println("Inside the Constructor of Child"); } public void display(){ System.out.println("Value1 === "+value1); System.out.println("Value2 === "+value2); System.out.println("Value3 === "+value3); System.out.println("Value4 === "+value4); } } public static void main(String args[]){ ConstrucChild c1 = new ConstrucChild(); c1.display(); }
  • 16. Object Oriented History The sense of object-oriented programming term seems to make their first appearance at MIT in the late 1950s Object-oriented programming is modeled on how in the real world objects are made up of many kinds of smaller objects. The Smalltalk language, which was developed at Xerox PARC (by Alan Kay and others) in the 1970s, introduced the term object-oriented programming to represent the pervasive use of objects and messages as the basis for computation.
  • 17. Abstraction Abstraction(hiding implementation) focuses on the outside view of an object.. (i.e. the interface) Abstraction is an essential element for OO which manages the complexity. In a sense when someone works on a computer not necessary that he should know the working of each and every part of the computer. interface Customer { void printCustomer (int i); }
  • 18. Encapsulation Encapsulation (hiding information) prevents clients from seeing its inside view, where the behavior of the abstraction is implemented It is the mechanism that binds together state and behavior in manipulates and keeps both safe from outside interference and misuse. class Customer { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
  • 19. Inheritance It is the process by which one object acquires the properties of another object. This supports the hierarchical classification. Without the use of hierarchies each object would need to define all its characteristics explicitly. However by use of inheritance, an object need only define those qualities that make it unique within its class. Java use “extend” keyword to inherit properties and behavior from super to its sub class. class Customer { String name; public String getName() { } } class MemberCustomer extends Customer { int collectedPoints; }
  • 20. Polymorphism The ability of the object design to group object behavior from different types. So by using this, one object can be treated like another even it came from difference hierarchy. The programmers can focus on selected behavior by no need to know the exact type of object in advance and this is being implemented at runtime.
  • 21. Defining the Behavior public interface IFace_Printable { public void printNow(); }
  • 22. Defining Classes which are the same behavior public class CustomerInfo implements IFace_Printable{ @Override public void printNow() { System.out.println("Read Customer Table... CustomerInfo. Done."); } } public class ProductInfo implements IFace_Printable{ @Override public void printNow() { System.out.println("Reading Product Table... ProductInfo. Done."); } }
  • 23. Create Polymorphic Method public class PrintServer { private IFace_Printable iFacePrintable; PrintServer(IFace_Printable iFacePrintable){ this.iFacePrintable = iFacePrintable; } public void printNowWraper(){ iFacePrintable.printNow(); } }
  • 24. Create Test Client for the Polymorphic Method public class PrintClientApplication { private static CustomerInfo customerInfo = new CustomerInfo(); private static ProductInfo productInfo = new ProductInfo(); public static void main(String [] args) { new PrintServer(customerInfo).printNowWraper(); new PrintServer(productInfo).printNowWraper(); } }
  • 25. Danairat T. Line ID: Danairat FB: Danairat Thanabodithammachari +668-1559-1446 Thank you