The method below is known as a getter. It has a ‘public’ access modifier so external classes can call this method to retrieve the data held in the accountNum field. Next to the access modifier we can see the type of data this method will return, in this case an ‘…
The Inquisitive Dev
Nice article about encapsulation.
But setters and getters DO violate encapsulation
Why would you have them ?