Yesterday i got confused with following question in an aptitude exam. Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit() in Class A from Class C. ???? Options:1.super.doit()2.super.super.doit()3.A.this.doit()4.this.doit().
Is this a valid question?If so whats the answer?Is super.super a valid one.??? Regards, Anand
hi anand , what about the access modifier of the method ,also super.super is not a valid one.i feel like the question itself is not clear. 1:super.doit() will invoke the classB doit() 2:super.super.doit(),compilation error 3:A.this.doit(),no idea..:) 4:this.doit();will invoke doit() in C
Sol:what i found is like ,u can put super.doit(); in B constructor and if u create the C object it will invoke A 's doit() ..,:)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.