Guest User

Untitled

a guest
Jul 20th, 2020
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public class Main2 {
  2.  
  3.     static class A {
  4.         String str = "abc";
  5.  
  6.         public A() {
  7.             print();
  8.         }
  9.  
  10.         void print() {
  11.             System.out.println(str.length());
  12.         }
  13.     }
  14.  
  15.     static class B extends A {
  16.         String str = "ab";
  17.  
  18.         public B() {
  19.             System.out.println(str.length());
  20.             print();
  21.         }
  22.  
  23.         @Override
  24.         void print() {
  25.             System.out.println(str.length());
  26.         }
  27.     }
  28.  
  29.     public static void main(String[] args) {
  30.         new B();
  31.     }
  32. }
Add Comment
Please, Sign In to add comment