forked from kotharigaurav6/itep5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCDemo10.java
41 lines (39 loc) · 938 Bytes
/
CDemo10.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// program showing the concept of constructor chaining
class Student
{
int rno;
double per;
String name;
Student(){
this(101);
System.out.println("default constructor called");
}
Student(int rno)
{
this(rno,56.67);
}
Student(int rno,double per)
{
this(rno,per,"Andrew Anderson");
}
Student(int rno,double per,String name)
{
this.rno=rno;
this.per=per;
this.name=name;
display();
}
void display()
{
System.out.println("Roll Number : "+rno);
System.out.println("Percentage : "+per);
System.out.println("Name : "+name);
}
}
class CDemo10
{
public static void main(String args[])
{
Student s = new Student();
}
}