The struggle for access

  • 7
  • Locked
Before you is a program that displays information about a person. Unfortunately, it doesn't compile. Change the minimum required number of access modifiers in the Person class for the code to compile.
You can't complete this task, because you're not signed in.
Comments (9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 14 , Mumbai , India
25 September, 15:14
I don't think given soution is correct, Can anyone explain me? As per me every method must be public in Person class
UltraGameCoder Java Developer
24 June, 11:20
The solution you get from 'Download correct solution' is considered correct. While it has protected on getFirstName which isnt correct as solution class does not inherit from Person.
Level 14 , Mumbai , India
25 September, 15:12
Same thought (protect method can not accessed by any class) As per my thought every method should be public in Person class
Vadim “迪姆哥”
Level 23 , Kazakhstan
13 October, 13:54
Sorry to tell you guys, but you are wrong. As class Solution and class Person both reside into same Package, protected methods of Person class will be visible inside Solution class...
Level 21 , Norway
20 December 2021, 21:42
Strange wording on the second point. Maybe try "Only change the access modifiers that prevent the program from compiling" instead?
Vadim “迪姆哥”
Level 23 , Kazakhstan
13 October, 13:53
Chris McClinch
Level 14 , Ashburn, United States
21 October 2021, 11:15
It should probably be made clearer in the task spec that you need to edit the file. This is the first task that calls for an edit to anything other than, and I know I spent a fair amount of unproductive time trying to declare everything in Solution public before finally trying to instantiate a new public Person class and getting the error message that got me on the right track.
Level 11 , Irvine, United States
23 September 2021, 04:35
I don't know what does it mean. Could somebody give me a hand?
PeterC Android Developer
26 September 2021, 17:46
It means that certain methods aren't visible from the class in the Main.class. You need to switch modifiers.