File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: super() question - from sierra/bates practice exam