# Mock Object

A controlled stand-in used to verify how code interacts with a dependency.

## What is **Mock Object** in Java?

**Mock Object** — A controlled stand-in used to verify how code interacts with a dependency.

```java
interface Clock {
    int hour();
}

class MorningTest {
    Clock fakeClock = () -> 9;
}
```

Level: Freelancer · [More Java terms at this level](https://www.ask-codey.com/glossary/subjects/java/freelancer)

Updated: September 27, 2026

## In other subjects

- [Mock Object in C#](https://www.ask-codey.com/glossary/mock-object-c-sharp)

Source: https://www.ask-codey.com/glossary/mock-object
