• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access Modifiers pg 26 k&b book(doubt)

 
aslika bahini
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


output:

Moo says...wow baby
zoo says...wow baby


when I try to invoke the coolMethod() using Moo instance(Moo m = new
Moo()) (i.e) m.coolMethod() in the line #1. it's not called bcoz of
run time i guess...but when i invoke inside useMyCoolMethod() of the
Moo class. it's got invoked.(which is also invoked by the same
instance Moo i guess..)

may I know what is wrong with my understanding..

Thanks in Advance
regards
samura







 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use real words (like "because" rather than "bcoz"). Thanks!
 
Fedry Kemilau
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while m.coolMethod() is invoked, it is returning String. So you should assign it to variable, or print it directly.

Example: System.out.println(m.coolMethod());
 
aslika bahini
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks fedry! I didn't realize that...


regards
samura
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic