This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes super() question - from sierra/bates practice exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "super() question - from sierra/bates practice exam" Watch "super() question - from sierra/bates practice exam" New topic
Author

super() question - from sierra/bates practice exam

Rachel Glenn
Ranch Hand

Joined: Oct 24, 2012
Posts: 95
GIVEN:


WHAT IS THE RESULT?

The answer is that COMPILATION FAILS AT LINE #1 because "only instance methods can be overriden, and calls to super only apply to overriden methods".



I don't get this. Can someone explain? It seems valid to me.... I would have guesses that this compiled!
Deepak Kumar Jha
Greenhorn

Joined: Feb 07, 2013
Posts: 17

first of all you cannot use super keyword in static context. that is at line 9 super.getRating2() is not valid.

after removing super the program is compiling and running fine. output: 42 43 .
Rachel Glenn
Ranch Hand

Joined: Oct 24, 2012
Posts: 95
ugh, I am now embarassed I even asked this question. Of course you can't use super from within a static method! That is the same as trying to use this. thank you!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: super() question - from sierra/bates practice exam