File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

immutable

dhana rangu
Ranch Hand

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

A.java.lang.Math
B.java.util.String
C.java.util.StringBuffer
D.java.lang.Boolean
E.java.lang.Object

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

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.
Cheers,
Rama
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. <br />- What truth? <br />- That there is no spoon!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: immutable