File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes help needed on Inner classes program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "help needed on Inner classes program" Watch "help needed on Inner classes program" New topic

help needed on Inner classes program

Naveen Megharaj
Ranch Hand

Joined: Feb 13, 2009
Posts: 39
The code goes like this

Above program produces the output as:

But i was expecting it as:

Since class C extends inner class -class B and overrides the 'runNOw()' method and hence a call to 'runNow() ' method on reference variable of type "B1" which points to an object of type C1 should produce the output as "Out". But its not doing so.....can anybody explain why.....?
Devaka Cooray
ExamLab Creator

Joined: Jul 29, 2008
Posts: 3910

This question is from my ExamLab SCJP exam simulator. When posting questions again, please QuoteYourSources.

You are getting that output because Java is case-sensitive. In other words runNow() is not equivalent for runNOw()

Hint: ExamLab has a "Copy Program" button which can be used to copy the entire program in to the clipboard.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
Precede the runNOw method with the @Override annotation and see what happens when you try to compile the class. And Devaka Cooray is correct about quoting sources.
I agree. Here's the link:
subject: help needed on Inner classes program
It's not a secret anymore!