Hi Jordan, Yes methods defined in interfaces can be synchronized. Since each class that implements the method will be required to handle it accordingly. No, private methods can not be overridden because they are not visible by any other class (including subclasses). Yes, transient variables can be written to output files. JLS only specifies that transient variables will not be serialized when the class is serialized. Regards, Manfred.
methods in interface cannot be synchronized. see the following compile message: <code> Interface methods can't be native, static, synchronized, final, private, or protected. </code> Hope it helps. Guoqiao
Originally posted by jordan gong: Dear Helper: Can the methods in interface be synchronized? Can private method be overriden? Can transient variable be written to output files? Thanks.
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
Hi Jordan, Can the methods in interface be synchronized? No, this keyword is not allowed. Can private method be overriden? You can override a method that is visible to the subclass.Since the private methods are not, you cannot override them. Can transient variable be written to output files? Yes you can!However, you cannot expect this variable to be serialized. Hope this helps, Sandeep
posted 19 years ago
Dear Helper: I am totally confused. Some people state method in interface can be synchronized, some state cannot. Which one is correct? thanks.
posted 19 years ago
Hi Jordan, A method declared in an interface may not be declared synchronized; however, a method declared in a class which is declared within an interface can be synchronized.
If you remove the comments in front of the methodA line above and try to compile you will get an error. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform