What about Math class??? Which of the following represent immutable classes? a) String b) Double c) StringBuffer d) Math
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
posted
0
I would say yes, Math class is immutable. All methods of Math class are static, so I cannot have new behavior by overriding it. Also, the constructor is private so I cannot instantiate athe class. Regds. - satya
I think the term "immutable" is completely meaningless for the Math class. "Immutable" is used to refer to objects, to indicate that the instances of a class are unchangeable. With the Math class, it's not even possible to create any objects, so the term "immutable" doesn't really apply, in my opinion. I suppose you could answer this one either way - it's a vague question.
"I'm not back." - Bill Harding, Twister
manal
Ranch Hand
Joined: Aug 17, 2000
Posts: 45
posted
0
hi ... u cant make a instance of maths class so there is no question of its immutebility .... there should be some object on which we could immutebility ... corrrrect me if i m wrong ...... manal ...
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
posted
0
Well, the way I was thinking of immutable is that "I cannot change the behavior of the class/obj" With this thought in mind, I said yes. Sure it is vague. Regds. - satya
Karthik Subramanian
Greenhorn
Joined: Aug 23, 2000
Posts: 27
posted
0
Hi all, I completely agree with the sheriff.When we can't even create an object of a class how can we think of changing it's contents.String and Double classes are examples of immutable classes.
Deepak M
Ranch Hand
Joined: Jul 10, 2000
Posts: 124
posted
0
If we get this qt in the exam and we DON't select Math class as immutable, that would mean Math class is mutable. However, thats not the case. Therefore, I think its better off to choose Math class as immutable. Vague answer for a vague qt.