Created
August 5, 2020 08:00
-
-
Save AakashCode12/9a41c7a65cc8d908eccbf6b9f0d15dd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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