This repository contains Object-Oriented Programming (OOPs) examples in Java.
It demonstrates different OOPs concepts like:
- Classes & Objects
- Constructors
- Copy Constructors
- Method Overloading
- Inheritance (Single, Multi-level, Hierarchical, Hybrid)
- Interfaces
- Real-world examples (Employee, Hacker, Car, Student, User, etc.)
- Small Java Programs (like FizzBuzz + Prime Numbers)
Hello! I am Muhammad Saqlain Shoukat also known as Dark Wolf founder and developer of Coding Chat Room, a passionate learner and creator in the field of Web Development, Cybersecurity, Programming, and DevSecOps.
🔹 My mission is to make complex technical concepts simple and easy so that students and professionals can learn without confusion.
🔹 On my platforms, I share tutorials, study notes, and practical tips about Linux, Ethical Hacking, Development, Programming and Cybersecurity.
🔹 I believe in learning by sharing — the more we teach, the more we grow.
Employee,Hacker,Car,Student,User→ Basic OOPs examplesUnknown→ Method Overloading examplesStudentGradingSystem→ Conditional logic with OOPShape,Circle,Animal,Fruit,Weapon→ Inheritance examplesOops.java→ Main file to run different code snippets
One special program included here is a modified FizzBuzz that also checks for prime numbers:
public class Oops {
public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.println(i + ":" + " FizzBuzz");
} else if (i % 3 == 0) {
System.out.println(i + ":" + " Fizz");
} else if (i % 5 == 0) {
System.out.println(i + ":" + " Buzz");
} else if (prime(i)) {
System.out.println(i + ":" + " Prime");
}
}
}
public static boolean prime(int num) {
if (num <= 1) {
return false;
}
for (int i = 2; i <= num / 2; i++) {
if (num % i == 0) {
return false;
}
}
return true;
}
}- Clone or download this repository.
- Open in VS Code / IntelliJ / Eclipse or any Java IDE.
- Compile and run:
javac Oops.java
java Oops2: Prime
3: Fizz
5: Buzz
7: Prime
11: Prime
15: FizzBuzz
17: Prime
23: Prime
29: Prime
...
If you found this helpful and want to learn more about web development, programming, and resources, follow me here and Star this Resporatory:
- 🎥 YouTube: Coding Chat Room
- 📸 Instagram: @codingchatroom
- 💻 GitHub: Saqlain Web Developer
💡 I share tutorials, tips, and resources to make learning cybersecurity and coding easier.
Don’t forget to subscribe & follow for more updates and Star this Resporatory 🚀
Learning and practicing Java OOPs concepts step by step.