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

what is the exact definition of "immutable"?

 
Steven Zeng
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a scjp question :
which of the following classes produce immutable object :
a java.lang.Double
b java.lang.StringBuffer(i know it is false)
c java.lang.Boolean
d java.lang.Math
 
Mike Shn
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Immutable means, once created, the contained value can't be changed.
P.S Do you preparing to take the 310-025 exam?
[ June 12, 2002: Message edited by: Mike Shn ]
 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the answer is Double and Boolean. Math class doesn't have any public constructors, so an instance can't be created.
 
Akhilesh Varma
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all wrapper classes and the string class objects are immutable so ans is double and boolean
 
Steven Zeng
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ,all .I agree at your answer .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic