Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Math

 
Doit
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about Math class???
Which of the following represent immutable classes?
a) String b) Double
c) StringBuffer d) Math
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
manal
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic