CS Java Concepts Handout
CS Java Concepts Handout
2. Abstraction
Definition: Hiding complex implementation details and exposing only
essential parts.
Java Mechanism: Abstract classes and interfaces.
Java Example:
abstract class Animal {
abstract void makeSound();
}
class Dog extends Animal {
void makeSound() {
System.out.println("Bark");
}
}
4. Boolean Tests
Definition: Expressions that evaluate to true or false.
Java Example:
boolean isAdult(int age) {
return age >= 18;
}
5. If-Then-Else
Definition: Executes code based on condition outcomes.
Java Example:
int score = 85;
if (score >= 90) {
System.out.println("Grade: A");
} else if (score >= 75) {
System.out.println("Grade: B");
} else {
System.out.println("Grade: C");
}
9. Flowcharts
Definition: Visual diagrams representing steps and decisions in
algorithms.
Symbols:
- Oval: Start/End
- Rectangle: Process
- Diamond: Decision
Example Flow:
Start -> [Input Number] -> (Is Even?)
/ \
Yes No
/ \
Print "Even" Print "Odd"
10. Algorithms as Pseudocode
Definition: Plain language step-by-step plan to solve problems.
Example:
1. Set max = first element
2. For each element in array
a. If element > max
i. Set max = element
3. Print max