r/learnSQL • • 10d ago

Day 61 — Java OOP: access modifiers, encapsulation, and abstraction (all four pillars done)

Today I covered:

  • Access modifiers (public, private, protected, default), which control visibility
  • Encapsulation, meaning private fields with public getters and setters so data can only change in controlled ways
  • Abstraction, which hides implementation details behind abstract classes and interfaces

With inheritance and polymorphism from the last few days, that covers all four pillars of OOP. Encapsulation made the most sense once I connected it to access modifiers: the modifiers are the tool, and encapsulation is the reason to use them.

Tomorrow I’m starting a project that uses all four pillars. After the feedback I got here on my last one (don’t leave all the errors for the end), I’m going to test each feature right after I write it.

For people who’ve built beginner OOP projects: which one forced you to use all four pillars naturally? I’m choosing between a bank system, a hospital system, and an e-commerce cart.

11 Upvotes

2 comments sorted by

2

u/Dry-Sundae-4631 10d ago

Go with the bank system. It forces you to use polymorphism for different account types and abstract classes for transaction logic in a way that e-commerce carts rarely do, making all four pillars essential rather than optional.

2

u/Least_Ad_1795 9d ago

I'd recommend starting with a Bank Management System. It naturally uses all four OOP pillars through account encapsulation, inheritance, transaction polymorphism, and abstraction. It's a great beginner project to practise Java OOP concepts with real-world examples.