Sunday, May 12, 2019

what will be the output of the following code?

Problem statement:
what is the output of the following code?
  1. interface Test1 {
  2.     default void run() {
  3.         System.out.println("test1");
  4.     }
  5. }
  6. interface Test2 {
  7.     default void run() {
  8.         System.out.println("test2");
  9.     }
  10. }
  11. public class A implements Test1, Test2 {
  12.     public void run() {
  13.         System.out.println("A");
  14.     }
  15.     public static void main(String args[]) {
  16.         A a = new A();
  17.         a.run();
  18.         Test1 t1 = new A();
  19.         t1.run();
  20.         Test2 t2 = new A();
  21.         t2.run();
  22.     }
  23. }
Output:
A
A
A

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...