File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ //Constructors
2
+ class Student {
3
+ int rn ;
4
+ String name ;
5
+ String subject ;
6
+ static final String instituteName = "APSMind" ;
7
+ Student (){
8
+ System .out .println ("I am default constructor." );
9
+ }
10
+ Student (int rn ,String name ){
11
+ System .out .println ("I am parametrized(2) constructor." );
12
+ this .rn = rn ;
13
+ this .name = name ;
14
+ }
15
+ Student (int rn ,String name ,String subject ){
16
+ this (rn ,name );
17
+ System .out .println ("I am parametrized(3) constructor." );
18
+ this .subject = subject ;
19
+ }
20
+ public void showStudent (){
21
+ System .out .println (rn );
22
+ System .out .println (name );
23
+ System .out .println (subject );
24
+ System .out .println (instituteName );
25
+ }
26
+ }
27
+
28
+ class Simple {
29
+ public static void main (String [] args ){
30
+ Student s = new Student (1 ,"Ramu Kaka" );
31
+ //s.instituteName = "ABCDEFG";
32
+ s .showStudent ();
33
+
34
+ Student s2 = new Student (2 ,"ABCX" ,"Java" );
35
+ s2 .showStudent ();
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments