Skip to the content.

Methods and Control Structures FRQ

Methods

What are methods?

  • Reusable code that performs specific tasks.
  • Helps break down programs into manageable parts.

Key Parts of a Method:

  • Declaration: Defines the method (e.g., public int add(int a, int b)).
  • Return Types: Specifies what the method returns (int, void, etc.).
  • Parameters: Inputs for dynamic behavior.

Types of Methods:

  • Instance: Belongs to objects (e.g., myObject.method()).
  • Static: Belongs to the class (e.g., ClassName.method()).