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
getId()
which will return its value. getId()
which will return its value. Correct Option is : B
A. is wrong. This will not allow others to read or write.
B. is a standard way of providing read only access to internal variables.