The IT Certification Resource Center

Featured Deal

Get CompTIA, Cisco, and Microsoft training courses free for a week.
Learn More ❯

Question 6:

Given the code below, and making no other changes, which access modifiers (public, protected or private) can legally be placed before myMethod() on line 3? If line 3 is left as it is, which keywords can legally be placed before myMethod on line 8?

1.  class HumptyDumpty
2.  {
3.      void myMethod() {}
4.  }
5.
6.  class HankyPanky extends HumptyDumpty
7.  {
8.      void myMethod() {}
9.  }
A. private or nothing (i.e. leaving it as it is) on line 3. Nothing (i.e. leaving it as it is) or protected or public on line 8.
B. public or protected on line 3. private or nothing (i.e. leaving it as it is) on line 8.
C. nothing (i.e. leaving it as it is) or protected or public on line 3. private or nothing (i.e. leaving it as it is) on line 8.
D. None of the above