Saturday 12 May 2012

Overriding


Q>What is the Output of this code?

class Parent {
    Number get() {
        return 1;
    }
}

class Child extends Parent {
    Integer get() {
        return 2;
    }
}

public class Test {
    public static void main(String[] args) {
        Parent yo = new Child();
        System.out.println(yo.get());
    }
}

***Output is in comment.

2 comments:

  1. According to Stanford Medical, It is indeed the SINGLE reason this country's women live 10 years more and weigh on average 42 pounds less than us.

    (By the way, it really has NOTHING to do with genetics or some hard exercise and really, EVERYTHING to about "how" they eat.)

    P.S, What I said is "HOW", not "WHAT"...

    Click on this link to see if this quick questionnaire can help you discover your true weight loss possibility

    ReplyDelete