Sunday, May 12, 2019

what is the output of the program?

Problem statement:
what is the output of the following code?
  1. public class A {
  2.     public static void showMe() {
  3.         System.out.println("A");
  4.     }
  5. }
  6. class B extends A {
  7.     public static void showMe() {
  8.         System.out.println("B");
  9.     }
  10. }
  11. class C extends B {
  12.     public static void showMe() {
  13.         System.out.println("C");
  14.     }
  15. }
  16. class Main {
  17.     public static void main(String[] args) {
  18.         A a = new B();
  19.         a.showMe();
  20.         A a1 = new A();
  21.         a1.showMe();
  22.         B b = new C();
  23.         b.showMe();
  24.         C c = new C();
  25.         c.showMe();
  26.     }
  27. }
Output:
A
A
B
C

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...