Today I just want to share with you some java basics mainly about access and non access modifiers.
1.Class name should be noun.
2.Interfaces should be adjectives.
3.Methods should be verb-noun.
4.Constants should be uppercase with underscores and static final.
5.JavaBeans should use the camelCase naming convention. set, get, is, add and remove..
1.Identifiers must start with a letter, a currency character, or a connecting character such as the underscore. Identifiers cannot start with a number.
2.After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.
3.There is no limit to the number of characters an identifier can contain, Identifiers are case sensitive.
Access modifiers: public, protected and private.
No access modifiers: strictfp, final and abstract.
1-Class only public or default.
2-Public class visible to all java classes in all packages.
3-Final classes can't be sub classed.
4-If class contains at least abstract method then the class should be marked as abstract.
5-Can't mark class or method as abstract final.
6-Class implements interfaces then all interfaces methods must be implemented and must be public.
7-Interfaces can have only abstract methods.
8-All interface methods are implicitly public and abstract.
9-All interface variables must be public static final explicitly declared or by default implicitly.
10-Interface methods mustn't be static.
11-Can't mark interface method final or strictfp or native.
12-Interface extends interfaces only, can extend more than one interface.
13-Abstract and final can't be used together.
Default Access (Package only): access only form same package.
Protected (Package+Kids): same as default with only one difference (any class extends class can access protected members even if not in the same package).
First concrete subclass must implement all abstract methods of the super classes.
Can't mark method as abstract and final, private abstract or abstract static.
Synchronized: applied only to methods or code blocks.
Native: applied only to methods (native void m();) without method body like the abstract method.
Strictfp: applied only to classes or methods but not variables.
Transient and Volatile: applied only to variables.
Transient: tell JVM to skip variable when object serialization.
Volatile: tell JVM any thread access this variable must be reconcile its own private copy of variable with the master copy on memory.
Can't mark constructor as static or final or abstract and can't be prefixed with void (will be normal method).
Left most bit represent the variable sign, 1 negative and o positive.
Local variables are always on stack not in the heap.
Enums outside class can't be private or protected, it can be default or public (require separate file), can't be declared inside methods and can end with semicolon or not.
No final object in java but only final reference.
1-From same class: public, protected, default and private.
2-From any class in same package: public, protected and default.
3-From subclass in same package: public, protected and default.
4-From subclass outside same package: public and protected.
5-From any non subclass class outside the package: public only.