Saturday, March 12, 2011

java access modifiers


1) A top level class can have public, abstract and final as access modifiers. To make the class default do not specify any access modifier.
2) A top level interface can have public and abstract as access modifier
3) The string class is a final class. Final classes can improve performance as the methods are expanded inline.
4) All the methods of final class are also final.
5) Transient keyword can only be applied to member variables and it makes those variable non-persistable while serializing the object.
6) Java interfaces cannot have transient variables.
7) Volatile variables maintain a master copy in addition to the local copy of each thread and each thread has to keep its copy in sync with the local copy. They are useful to avoid concurrency problem when synchronization is not an option. They are somewhat slower.
8) The only modifier that can be applied to local variables in final.

No comments:

Post a Comment