Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Mira Chandra Kirana

Informatics Engineering
Politeknik Negeri Batam
MESSAGE How software
objects interact
and communicate
with each other?

Message

How to instruct a
class or an object to
do an assignment?
MESSAGE (CONT.)

Object of
destination

Name of method

Any parameters that


method required
MESSAGE (CONT.)
Example

System.out.println (“This is a message”);

? ? ?
METHOD

Needed to process a
message

Method

data can only be accessed by


METHOD (CONT.)

Two kinds of method

Instance
Class Methods
Methods

Defined for a class Defined for an


(Static method) object
METHOD (CONT.)
Example of Class Method :

Display text to screen:


System.out.print(“I am a pretty
one”);

Convert String to double :


b = Double.parseDouble(a);
METHOD (CONT.)
Example of instance method :

public void IWrite(String texting)


{
System.out.println(texting);
}
EXERCISE IN CLASS

1. Write three “instance methods” for the Cat1


object, that represents “the sound of a cat”,
“a cat walking”, and “a cat eating”.
2. Give the explanation of each methods.
TASK
Summarize "messages and methods" in your
own words based on one or more trusted
references!

Submit your exercise and task as “pdf “named T3_NIM

You might also like