Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class G{
- static int g = 0;
- G(){
- }
- }
- class E extends G{
- static int e = 0;
- E(){
- g++;
- }
- }
- class Q extends G{
- static int q = 0;
- Q(){
- g++;
- }
- }
- class A extends E{
- static int a = 0;
- A(){
- e++;
- g--;
- }
- }
- class B extends Q{
- static int b = 0;
- B(){
- q++;
- g--;
- }
- }
- class C extends Q{
- static int c = 0;
- C(){
- q++;
- g--;
- }
- }
- class D extends Q{
- static int d = 0;
- D(){
- q++;
- g--;
- }
- }
- public class ChildCountingFinal {
- public static void main(String[] args){
- G ob1 = new G();
- E ob2 = new E();
- A ob3 = new A();
- Q ob4 = new Q();
- B ob5 = new B();
- C ob6 = new C();
- D ob7 = new D();
- System.out.println("G " + ob1.g);
- System.out.println("E " + ob2.e);
- System.out.println("A " + ob3.a);
- System.out.println("Q " + ob4.q);
- System.out.println("B " + ob5.b);
- System.out.println("C " + ob6.c);
- System.out.println("D " + ob7.d);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment