• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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

 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic