This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static inner class Question!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static inner class Question!!" Watch "static inner class Question!!" New topic
Author

static inner class Question!!

Afzal Rehman
Ranch Hand

Joined: Dec 16, 2009
Posts: 39

Why the Answer is "High High", Anyone please give explanation please.


SCJP 6.0
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263

Because of private access modifier its not overriding. And array is defined of type A[] so method in A will be called.


SCJP 1.5(97%) My Blog
Afzal Rehman
Ranch Hand

Joined: Dec 16, 2009
Posts: 39
Many Thanks
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

No Overriding here, then no Virtual Method Invocation......


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
I understand that there is no overriding here, but I am still not clear with the second output. Since the method runNow() is private it is not visible outside the class. Then how is that with new C() the output is high. Could somebody please elaborate?

Thanks
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234

I understand that there is no overriding here, but I am still not clear with the second output. Since the method runNow() is private it is not visible outside the class. Then how is that with new C() the output is high. Could somebody please elaborate?


If you know there is no overriding then how could runNow() of C class will invoke?

If there is overrding only then C class method will get invoked in this case.
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
Brij Garg wrote:

I understand that there is no overriding here, but I am still not clear with the second output. Since the method runNow() is private it is not visible outside the class. Then how is that with new C() the output is high. Could somebody please elaborate?


If you know there is no overriding then how could runNow() of C class will invoke?

If there is overrding only then C class method will get invoked in this case.


I never said that the runNow() of C will be invoked. The private method runNow() is not visible in class C then how are we getting "high". Still not clear.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

private method is hiding into a class in where it is declared . you cant override a private method , instead you are redefining the method in inner class.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: static inner class Question!!
 
Similar Threads
polymorhic...or not!
help needed on Inner classes program
Devaka Coorey Exam Lab
Question from ExamLab
Dynamic assignment of an Array