This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
1)Question class Super { int index = 5; public void printVal() { System.out.println( "Super" ); } } class Sub extends Super { int index = 2; public void printVal() { System.out.println( "Sub" ); } } public class Runner { public static void main( String argv[] ) { Super sup = new Sub(); System.out.print( sup.index + "," ); sup.printVal(); } } The result is (5,Sub).Why is not (2,Sub)?Who know reason. Thank you. 2)Question The finally statment execution finish .The rest of the method countinue to run.(True or False)?
chetan nain
Ranch Hand
Joined: Jun 21, 2000
Posts: 159
posted
0
two points: 1. overridden method called depends on the class denoted by the reference during runtime. 2. shadowed member variable called depends on the type of the reference . retry your analysis for your second answer, the data is insufficient to warrant an answer. for example, if an uncaught exception occured, rest of method would be skipped hth, chetan
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.