• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Math

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about Math class???
Which of the following represent immutable classes?
a) String b) Double
c) StringBuffer d) Math
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic