Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A few questions! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A few questions!" Watch "A few questions!" New topic
Author

A few questions!

laura_zhou
Greenhorn

Joined: Oct 15, 2000
Posts: 1
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

Joined: May 06, 2000
Posts: 396
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

Joined: Oct 16, 2000
Posts: 16
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A few questions!