r/JavaProgramming • • Dec 22 '25

Day 7 of learning Java

I relearned the Abstraction and Encapsulation OOP concepts on Day 6 and refactored the Mortgage Calculator project.

Open to suggestions on how to improve the project, OOP-wise

18 Upvotes

7 comments sorted by

View all comments

1

u/souroexe Dec 22 '25

I have few questions :-

  1. Why have u used byte data type for years ?

  2. Why have u done Console.readNumber() ?

  3. Why have u taken final keyword for the instance variables ?

1

u/BigCommunication5136 Dec 22 '25
  1. If you watch closely, the allowed number of years is up to 30 and byte is more than enough.

  2. I encapsulated the logic for reading a value from a user, and I didn’t want to initialize a new object whenever I want to input a value that’s why I used the static keyword

  3. TBH it was a suggestion from intelliJIDE