208k views
4 votes
Which of the following is not true about designing classes? In order for class information to be printed instead of a memory address, a toString method should be declared. The constructor must be declared as public. All class variables should be declared as private. To test for equality the programmer should define an equals method. All methods should be declared private.

User Henk
by
7.1k points

1 Answer

2 votes
'All methods should be declared private' is not true for classes. One should be able to change the properties of objects, and to do this safely and in a controlled manner, some public methods are declared. Some private methods can also be declared for more potentially sensitive operations for being called from within the class.
User John Hadikusumo
by
7.7k points