Skip to content

Instantly share code, notes, and snippets.

@sumon-sarker
Created January 29, 2018 11:59
Show Gist options
  • Save sumon-sarker/76ce664ba75d7480d789f42892b42e99 to your computer and use it in GitHub Desktop.
Save sumon-sarker/76ce664ba75d7480d789f42892b42e99 to your computer and use it in GitHub Desktop.
How JAVA constructor works
/*File : Html.java*/
import packages.*;
public class Html extends Php{
public Html(){
super(); /*Parent Constructor Initialization*/
}
public static void main(String args[]){
System.out.println("Welcome to HTML 5");
Html html= new Html(); /*Self Constructor Initialization*/
}
}
/*======================File : packages/Php.java======================*/
package packages;
public class Php extends MySql {
public Php(){
System.out.println("PHP has been initialized");
}
}
/*======================File : packages/MySql.java======================*/
package packages;
public class MySql {
public MySql(){
System.out.println("MySql has been initialized");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment