oop Programming Concepts
oop Programming Concepts
Programming Concepts
Definitions:
2. Java Environment
Java Installation & Setup:
• JDK (Java Development Kit): Tools for developing Java programs, including a
compiler.
• Eclipse IDE: An integrated development environment (IDE) used for writing and
running Java programs.
• Environment Variables: Settings that help the computer locate Java tools during
execution.
Java Features:
• Platform Independence: "Write once, run anywhere" capability via the Java Virtual
Machine (JVM).
• Object-Oriented: Java is built on classes and objects, encouraging modular, reusable
code.
Java Syntax:
• Case Sensitivity: Java is case-sensitive (e.g., variable and Variable are different).
• Class Names: Should start with an uppercase letter (MyClass).
• Method Names: Should start with a lowercase letter (calculateSum).
• Program File Name: Must match the public class name and end with .java.
• Public static void main(String[] args): The entry point for all Java programs.
3. Data Operations
Data Types:
Variables:
Constants:
• Final Variables: Use final to declare constants that cannot be changed (e.g., final
int MAX = 100;).
Statements:
4. Control Structures
Control Statements:
• Decision Making:
o if-else: Executes code based on conditions.
o switch: Chooses one of many code blocks to execute.
• Loops:
o for: Repeats code a fixed number of times.
o while: Repeats code while a condition is true.
o do-while: Executes code at least once before checking the condition.
• Branching:
o break: Exits a loop or switch statement.
o continue: Skips the current iteration of a loop.
Examples:
• if-else:
java
Copy code
if (age > 18) {
System.out.println("Adult");
} else {
System.out.println("Minor");
}
• for loop:
java
Copy code
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
5. Methods
Method Basics:
java
Copy code
returnType methodName(parameters) {
// code
}
Examples:
• Method Creation:
java
Copy code
public int addNumbers(int a, int b) {
return a + b;
}
• Method Overloading:
java
Copy code
public int add(int a, int b) {
return a + b;
}
Examples:
java
Copy code
class Car {
String model;
void start() {
System.out.println("Car started");
}
}
• Inheritance:
java
Copy code
class Animal {
void sound() {
System.out.println("Animal makes a sound");
}
}
• Key Terms: Understand definitions like algorithms, source code, object code,
machine code, compiling, and debugging.
• Data Types & Variables: Remember the different types of variables and how to
declare and assign them.
• Control Structures: Know how to use decision-making (if, switch), loops (for,
while), and branching (break, continue).
• Methods: Understand how to define methods, pass parameters, and use method
overloading.
• OOP Concepts: Grasp the basics of inheritance, encapsulation, abstraction, and
polymorphism.
• Java Syntax: Be aware of case sensitivity, class names, method names, and file
naming conventions.