Tuesday, August 12, 2008

Class, Method, and Variable Modifiers in java

1. class : Keyword used to specify a class.

2. interface : Keyword used to specify an interface.

3. extends : Indicate the superclass that a subclass is extending.

4. final : It makes impossible to
i) Extend a class
ii) override a method
iii) reinitialize a variable.

5. abstract :
i) If abstract is used to declare a class then it can’t be instantiated.
ii) If abstract used in a method then must be implemented by nonabstract subclass.

6. implements : To indicate the interfaces that a class will implement.

7. new : Used to instantiate an object by invoking the constructor.

8. native : Indicates that a method is written in a platform-dependent language.

9. synchronized : Indicates that a method can be accessed by only one thread at a time.

10. static : Makes a variable or a method belong to a class as opposed to an instance.

11. transient :
i) It Prevents fields from ever being serialized.
ii) Transient fields are always skipped when objects are serialized.

12. volatile : Indicates a variable may change out of sync because it is used
in threads.

No comments:

private methods on Interface

  Private methods can be used on interface from java 9.   This will help in     Avoiding code duplication.     Ensuring code re-usab...