(CGA) Object Behaviors Lesson

Object Behaviors

Behaviors of objects are defined through methods. Inheritance is a way to reuse methods already created in other classes.  All Actors have some basic behaviors in common. Those are in the Actor class.  Every subclass created from Actor will inherit those methods rather than duplicating the method in every class. The keyword to show an inheritance relationship is extends.   

code block:
public class SharedResources extends Actor
public class Bird1 extends SharedResources

Access the learning object below to learn more about inheritance.

Methods

Methods are made up of expressions and statements that tell an instances of a class how to perform a task.  

Methods are written to:

  • Command an object to perform an action
  • Ask an object a question to retrieve information

Access the learning object to learn more about using methods to create behaviors.

[CC BY 4.0] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION