• 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

Ques regarding immutable class

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was a question in 19 hadrdest questions by Bill Brogden.
Which of the following classes produce immutable objects. Select all correct answers.
a) java.lang.Double
b) java.lang.StringBuffer
c) java.lang.Boolean
d) java.lang.Math
The correct answer is a) and c).
I think even StringBuffer and Math class produce immutable objects. Please someone help me.
Thanx.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think only String and Wrapper class produce immutable object.
StringBuffer surely doesnt produce the immutable class, and that is one of the reason for having StringBuffer object.
I think MATH also doesnt produce immutable object.
Milind.
[This message has been edited by Milind Deodhar (edited December 07, 2000).]
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at this link, Ajith explained it great:
http://www.javaranch.com/ubb/Forum24/HTML/006116.html
Remeber that Math and StringBuffer are final classes meaning you can't subclass them, but that doesn't mean they are immutable.
 
ashwini srinivasan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Milind and Bill.
I got my doubt cleared.
String and wrapper classes produce immutable objects,
Math and StringBuffer classes are final. We can't subclass them.
 
reply
    Bookmark Topic Watch Topic
  • New Topic