• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

does toString () in wrapper classes are marked final?

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi ranchers!

In k&B book, pg 232 chap-3 (Assignments)...
It's mentioned that in wrapper classes toString() is marked final.
is that true? I checked out in API. but, I couldn't find any...


Thanks!
samura





 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Samura.

The method toString() is not marked as final in the Wrapper classes.

However if we consider that a final method is a method which cannot be overridden by a subclass, we can say that the method toString() of a wrapper class is final.
This because a wrapper class is final. It's cannot have a subclass and the method toString() can not be overridden.

Regards.
Collins
 
aslika bahini
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks collins!


with regards
samura
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...

You had it completely wrong....

the statement as in the book is as follows:

[B] relates to Wrapper Classes which, as we know, are marked final [/B]

.

let's see, what this sentence says:....

it says that toString() is a method that relates to wrapper classes...

and that these Wrapper classes are marked final.. i.e., you cannot subclass
them in anyway... which is true....

isn't it..>???

besides you should remember that we override the toString() method to tell the user of what the object does......
so in order to do such thing we have to override that particular method... which as per your Question states that's declared final.....
now we know that we cannot override a final method butwe have to use it .. as it was declared.... right..???...
so your assumption that toString() is marked final is wrong...

its the Wrapper classes that are marked final....

understood....
ok.
 
aslika bahini
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Hi sandeep,

I misunderstood it...Thanks

regards
samura

 
reply
    Bookmark Topic Watch Topic
  • New Topic