logo

Crowdly

Browser

Add to Chrome

--------------------------------- interface A_IF.java public interface ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

--------------------------------- interface A_IF.java

public interface A_IF {

void methodA ();

}

--------------------------------- class A.java

public class A implements A_IF {

@Override

public void methodA() {

System.out.println("A dummy implementation of methodA()");

}

}

--------------------------------- Main.java

public class Main {

public static void main(String[] args) {

// Quiz statement

}

static void myMethod(A_IF a){

a.methodA();

}

}

Which are (correct) uses of an anonymous class in Main.java, method main() (after "Quiz statement")?

1) 

A_IF a = new A();

2)

A_IF a = new A_IF () { };

3)

myMethod(new A_IF() {

@Override

public void methodA() {

System.out.println("A dummy implementation for methodA()");

}

});

4)

A_IF a = new A_IF () {

@Override

public int methodA() {

System.out.println("A dummy implementation for methodA()");

return 0;

} };

 

More questions like this

Want instant access to all verified answers on moodle.jku.at?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome