Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AakashCode12/9a41c7a65cc8d908eccbf6b9f0d15dd8 to your computer and use it in GitHub Desktop.
Save AakashCode12/9a41c7a65cc8d908eccbf6b9f0d15dd8 to your computer and use it in GitHub Desktop.
class DateMethod
{
int dd,mm,yy;
public DateMethod(){
dd=mm=yy=0;
System.out.println("This is the default constructor");
}
public DateMethod(int d,int m,int y){
dd=d;
mm=m;
yy=y;
System.out.println("This is the parameterized Constructor");
}
public void dispDate(){
System.out.println("The date is "+dd+"/"+mm+"/"+yy);
}
}
class constructorProgram{
public static void main(String args[]){
/*
This is the call for default constructor
*/
DateMethod d1 = new DateMethod();
d1.dispDate();
DateMethod d2 = new DateMethod(4,8,2020);
d2.dispDate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment