The moose likes Beginning Java and the fly likes Some Basic Doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Some Basic Doubts " Watch "Some Basic Doubts " New topic
Author

Some Basic Doubts

subhadeep chakraborty
Ranch Hand

Joined: Jul 29, 2006
Posts: 67
Hi,
I am confused with some questions, please answer in a simple way so that i can understand...
1) why are wait(), notify() and notifyAll() in the Object class although we use it only while threading?
2) why can't static and transient variables be serialized?
3) what is the difference between a argument and parameter?

Thanks and Regards,
Subhadeep
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

Originally posted by subhadeep chakraborty:
1) why are wait(), notify() and notifyAll() in the Object class although we use it only while threading?

So you can synchronize on any object you wish to, since all objects will inherit those methods. If it were methods of Thread then you could only synchronize on the thread.

2) why can't static and transient variables be serialized?

The transient keyword is invented just to prevent the variable from being serialized. Sometimes a variable isn't serializable, but you can reconstruct it from other information (such as an InputStream). Without the transient keyword the entire object would be non-serializable.

As for static - it's an instance of a class that is serialized. Static variables are not related to the instance but the entire class. If you would deserialize it, there is still the existing information in the static variable.

3) what is the difference between a argument and parameter?

I think it's just a matter of name calling. I mix them up myself sometimes.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some Basic Doubts