Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingOther conceptsNested classes

Anonymous classes properties

Fixing the code

Report a typo

What do you need to change to execute the code below?

class Action {
    public void doAction() {
        System.out.println("Doing an action");
    }
}


class Human {

    public void doYoga() {
        Action action = new Action() {
            public void doAction() {
                System.out.println("Doing yoga.");
            }
        }
        action.doAction();
    }
}
Select one option from the list
___

Create a free account to access the full topic