I also tried removing the "\n" from the SecondClass's SPECIFIC_ACTION_FOR_ANONYMOUS_SECOND_CLASS_PARAM. When I did that, it passed the first condition but still failed the other two Edit: I overrode the anonymous FirstClass's someAction() method and called the parent class method This solved the 3rd condition I created an anonymous SecondClass and overrode the someAction() method to print() instead of println() This solved conditions 1 and 2