Is there any way to create a test case, where you could confirm, that the student has declared an attribute as private? For example, if I would have the following assignment:
- Create a class called "Dog".
- The class has one private attribute "name".
- Create getter and setter methods for the name attribute. The name of the getter method should be getName. The name of the setter method should be setName.
Test case could be like:
// Create an object
Dog dog = new Dog();
// Assign/set name
dog.setName("Lassie");
// Print name using getter
System.out.println(dog.getName());
This way I can check that the getter and setter methods work, but how can I check that the name attribute is private and not public?