Problem statement:
what is the output of the following code?
what is the output of the following code?
- interface Test1 {
- default void run() {
- System.out.println("test1");
- }
- }
- interface Test2 {
- default void run() {
- System.out.println("test2");
- }
- }
- public class A implements Test1, Test2 {
- public void run() {
- System.out.println("A");
- }
- public static void main(String args[]) {
- A a = new A();
- a.run();
- Test1 t1 = new A();
- t1.run();
- Test2 t2 = new A();
- t2.run();
- }
- }
Output:
A
A
A
No comments:
Post a Comment