Declaration and access control

Declaration and access control

·         Identifier can begin with letters, underscore and currency chars.
·         Java bean methods should start with set, get, is, add, remove.
·         Final class cannot be sub classed. Final methods cannot be overridden. Final variables cannot be changed.
·         Final variables cannot be reinitialized; it must be initialized before the constructor completers.
·         Abstract class cannot be instantiated but it can run.
·         A abstract class may or may not include abstract method
·         Abstract methods are not implemented they end with a semi colon. They don’t have any body. Abstract methods cannot be private or final.
·         A single abstract method in the class means whole class declared abstract.
·         An abstract class can also contain non abstract methods.
·         The first concrete class to extend an abstract class must implement all abstract methods or be declared abstract.

·         If A is abstract class and it implements B it need not implement all the methods in B, it can leave the interfaced implementation on to its non abstract sub class.

·         A non abstract class implementing an interface must implement all methods, and must not declare any checked exceptions that are broader than the exceptions declared in the interface method.
·         Interfaces can have constants, which are always implicitly public, static, and final

·         Interface methods are implicitly public and abstract, hence cannot be declared static final, strictfp or native.

·         Interfaces are implicitly public hence implemented methods should also be declared public.
·         A class can extend one class and implement multiple interfaces.
·         An interface can extend multiple interfaces only.
·         Local variable can only have final modifier, and no other modifiers, they also don’t get default values.
·         Synchronized applies only to block and methods
·         The native modifier applies only to methods not to classes or variables.
·         A var arg parameter is declared as doStuff(int... x) { },
·         A var-arg method can have only one var-arg parameter.
·         In methods with normal parameters and a var-arg, the var-arg must come last.
·         Instance variables can't be abstract, synchronized, native.
·         Only variable and objects can be transient or volatile.
·         Static methods don’t have access to non static member.
·         Static methods cannot be overridden.
·         Any static Methods cannot call this, super.

No comments:

Post a Comment