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

A few questions!

 
laura_zhou
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.public class Final
{
private int val = 0;

void set (int i) { val = i; }

static public void main(String a[])
{
final Final anObj = new Final();
anObj.set(10);
anObj.val = 10;

Final bObj = new Final();
anObj = bObj;
}
}
If a class is final class, could the value of the class be changed?
So if the anObj.val = 10 is correct or not.
2.what difference between floor(-0) and floor(-0.0)?
why the result is different?
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi laura,
final class
-----------------------------------------------------------
the only restriction with final class is thatit can't be subclassed.u can always change the values of it's members.
so the anObj.val = 10 is correct.
------------------------------------------------------------

I don't have the answer to your second ques. right now. will try to find it out.
regards
deekasha
 
Manish Joshi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the question posted Your class status is not final only the name of the class is Final the concept final is lowercsed (Keyword) In your case the class is normal class with the name as Final Where as further what you have done is You made reference to that object of your class you are making final which results into that Now your reference (Better known in jaava is handle ) to he object cannot change his reference to any other object thats it Contents of the handle is final whereas the Object is still mutable
javaexams@yahoo.com
Manish - India
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic