Question 19
Back to Exercise
Do simple getters and setters make Java programs noticeably slower?
- A Yes, every call is expensive
- B No – the JIT compiler inlines small methods Correct
- C Only in loops
- D Only for static fields
Correct Answer: Option B
Encapsulation costs essentially nothing at run time.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!