• 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

A few questions!

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic