# Object-Oriented Programming

Source: https://cca.twango.dev/AP-Computer-Science/object-oriented-programming

# Object-Oriented Programming

## Classes

A class defines a type of object: a set of information (fields) and behaviors (methods).

## Instantiation

Instantiation creates an object from a class, usually by calling a constructor with `new`.

## Overloading

Overloaded methods have the same name and different parameter lists (number or types of parameters).

> [!warning] Correction to the original notes
> Renaming parameters alone does not create a different method signature. The original parenthetical claim that parameters can simply be named differently was misleading.

```java
public int doubleValue(int value) {
    return value * 2;
}

public double doubleValue(double value) {
    return value * 2;
}
```

Source: [Java Language Specification §8.4.9](https://docs.oracle.com/javase/specs/jls/se17/html/jls-8.html#jls-8.4.9).

Related: [[introduction-to-java|Introduction to Java]] · [[methods|Methods]]
