Engineering Full Stack Apps with Java and JavaScript
Consider the following class:
public class Test{ public int id; }
Which of the following is the correct way to make the variable 'id' read only for any other class?
Select 1 option
A. Make 'id' private.
B. Make 'id' private and provide a public method getId() which will return its value.
C. Make 'id' static and provide a public static method getId() which will return its value.
D. Make id 'protected'.