Week 5 — Methods
Apr 28 – May 2 · 4 lessons · Midterm at end of week
- 5-a Methods: The Why and the Header Five-piece header, declare vs call, the jump
- 5-b How a Method Call Actually Works Three-step protocol, pass-by-value, parameter mystery
- 5-c Return Values, void, and Composition Pick a return type, print vs return, methods composing
- 5-d Overloading, Scope, and Decomposition Signatures, local scope, designing 3–5 named verbs
Objectives
- Read any Java method header and name its five pieces
- Apply the three-step call protocol (evaluate args → bind by position → jump) to predict output
- State the pass-by-value rule for primitives and explain why "swap" doesn't swap
- Choose between
int,double,boolean,String, andvoidfor a problem - Distinguish printing from returning, and prefer returning when the caller might use the value
- Decide whether two headers form a legal overload pair or a duplicate-signature error
- Decompose an English problem statement into 3–5 static-method calls from
main