Bloomberg LP Interview Question
may i know why this is happening
can you give me some link where I can study this phenomena
sc is a reference to an object of type SubClass
printIt() method of SuperClass is overriden by SubClass and so sc.printIt() will be a call to printIt() method defined in SubClass
When sc.printIt(false) is executed, printIt(boolean val) is searched in SubClass. As it is not present, its superclass is searched.
So, printIt(boolean val) of SuperClass is called.
subclass
- vvarshne August 05, 2011superclass