Object-Oriented Programming (OOP)
Completion requirements
3. Use Cases
3.2. Practical Example: Sum of Squares (1 to n)
Compute the sum of squares (e.g., for n=3: 1 + 4 + 9 = 14).
Comparison of Paradigms
Paradigm | Focus | Control Flow | State Management | Java Use Case |
Functional | Mathematical functions | Implicit (Streams) | Immutable | Stream processing |
Declarative | Desired outcome | System-managed (SQL) | Minimal | JDBC queries |
Logic | Logical inference | Backtracking (tuProlog) | Facts/rules | Expert systems |
OOP | Objects (data + behavior) | Explicit (methods) | Mutable | Enterprise apps |
Structured | Disciplined control flow | Sequence, selection, iteration | Mutable | General algorithms |
Scripting | Automation, rapid tasks | Imperative (JavaScript) | Dynamic | JavaScript via Nashorn |