The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes immutable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "immutable" Watch "immutable" New topic


dhana rangu
Ranch Hand

Joined: Oct 01, 2003
Posts: 65
Which of the following java classes are immutable??

The answer is given as B,C.
But i doubt if StringBuffer class is immutable ..plz advise
Rama Kumar PV

Joined: Dec 26, 2003
Posts: 26
An object can be categorized as mutable if it can be changed internally (through the usage of methods).
Here, Math class cannot be instantiated and hence all it's methods are static. All wrapper classes are immutable along with String. StringBuffer represents mutable strings. So, possible answers can be, java.lang.Boolean and java.util.String and not StringBuffer.
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
The StringBuffer class is NOT immutable. And that is a fact.
[ January 10, 2004: Message edited by: Vicken Karaoghlanian ]

- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
I agree. Here's the link:
subject: immutable
It's not a secret anymore!