• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static inner class Question!!

 
Afzal Rehman
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
shivendra tripathi
Ranch Hand
Posts: 263
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Because of private access modifier its not overriding. And array is defined of type A[] so method in A will be called.
 
Afzal Rehman
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many Thanks
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Overriding here, then no Virtual Method Invocation......
 
bhanu chowdary
Ranch Hand
Posts: 256
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 256
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic