Skip to content

Instantly share code, notes, and snippets.

@eftakhairul
Last active December 29, 2015 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eftakhairul/7593368 to your computer and use it in GitHub Desktop.
Save eftakhairul/7593368 to your computer and use it in GitHub Desktop.
Learning Java and some tips
#Static initialization
All static initialization get call first before main method and contractor.
#constructor
If a sub class extends from parents class, then if you create the instance of Subclass, automatically parents constructor will get called.
#Protected Modifier
he protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.
#final
Final class can't be inherited and also final method can't be overridden.
#abstract
You can make any class abstract. If you make abstract, then you can't instantiate it.
If a class has at least one abstract method, then that class must itself be declared abstract.
abstract class may have contractor.
One abstract class can inherit another abstract class
abstract class can implement interface. But it doesn't require to implement interface's method. The child of abstract class will implement it.
#Overriding
If a subclass has a method which has same name, same signature and same return as parents. Then it will be considered as overriding
#static methods
Static methods are decided based on their declare type. That's mean it's actually statically bound.
Static method doesn't belong to an interface or abstract class. It only belongs to the real implementation.
#interface
The interface has default package-private visibility.
One interface can extend another interface
#casting
All casting checking based on the dynamic type in run time.
You can't cast super type by subtype.
#shadowing
If a local variable overrides a global variable, then this feature is considered as shadowing.
#hiding
If a subclass override the supertype static feature then this considered is hiding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment