Interview Questions

How Do You Test a "protected" Method?

JUnit Questions and Answers


(Continued from previous question...)

How Do You Test a "protected" Method?

When a method is declared as "protected", it can only be accessed within the same package where the class is defined.

In order to test a "protected" method of a target class, you need to define your test class in the same package as the target class.

(Continued on next question...)

Other Interview Questions