Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rule Round-up Game Question #108

 
Igor Stojanovic
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got confused when question #108 pop up:


They say that correct answer is 4,
doStuff() from B class gets called...

I dont understand why this should be,
if we declare doStuff() method to be static then correct answer would be 3.,
doStuff() from A class would be called...
they didnt say if method doStuff() was declared with default acces modifier or with static so I think that question should be more specific about acces modifier , plz correct me if I am thinking wrong


kind regard
Igor
[ February 19, 2005: Message edited by: Igor Stojanovic ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question states that "B overrides the doStuff() method inherited from A." To me, this implies that doStuff() is NOT static because if it was then B couldn't override it.

Layne
 
Igor Stojanovic
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx for quick answer I should learn english better first then java (english is my 3rd language)




kind regards
Igor
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the record, the question could be stated much more clearly by giving the code for class A and class B. In fact, if the code includes System.output.println() calls, the question could just ask what the output of the program would be.

And I would have never guessed that English is not your native language. You write very clearly and with correct grammar.

Layne
[ February 19, 2005: Message edited by: Layne Lund ]
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is not much space to ask a question in the Rule Roundup game. Not enough space to give the code for class A and class B.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It wouldn't take much room:

Well...maybe that wouldn't fit in the available space...hmm...

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic