Interactive Computer Science Tutoring

Learn programming concepts interactively

AHA Schools Logo

Object-Oriented Programming

Explore objects, their state, and behavior through interactive examples

What Is an Object?

Objects are fundamental building blocks in programming that mirror real-world entities. Just like real-world objects, software objects have state (properties/attributes) andbehavior (methods/functions).

This interactive page lets you explore different software objects, see their internal state, and trigger their behaviors.

Select an Object
Choose an object to interact with.
Create Custom Object
Bicycle (Object)Encapsulated
Type: Vehicle

State

Internal state is hidden (Encapsulation).

Behaviors

Java Code
Object-oriented representation of your selected object
/**
* Bicycle class demonstrating OOP concepts
* State: Properties that define the object's current condition
* Behavior: Methods that can modify the object's state
*/
public class Bicycle {
// State (Properties) - Private fields for encapsulation
private int currentSpeed;
private int currentGear;
private int pedalCadence;
private boolean isMoving;
// Constructor - Initialize object state
public Bicycle() {
this.currentSpeed = 0;
this.currentGear = 1;
this.pedalCadence = 0;
this.isMoving = false;
}
// Behavior (Methods) - Actions the object can perform
// Getters - Controlled access to private state
public int getCurrentSpeed() {
return this.currentSpeed;
}
public int getCurrentGear() {
return this.currentGear;
}
public int getPedalCadence() {
return this.pedalCadence;
}
public boolean getIsMoving() {
return this.isMoving;
}
// Main method for testing
public static void main(String[] args) {
Bicycle myBicycle = new Bicycle() ;
System.out.println("Created a new Bicycle!");
// Demonstrate object behavior
}
}
Activity History0/5
Recent object interactions

No operations yet

Start by adding or modifying elements