This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread 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 Murach's Java Servlets and JSP this week in the Servlets 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!!
 
jQuery in Action, 2nd edition
 
subject: super() question - from sierra/bates practice exam
 
Similar Threads
Overridden methods
question from master exam
Question about the explanation given for B&K exam question?
Master exam question
Overriding static methods