-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathDemo4.java
More file actions
30 lines (28 loc) · 956 Bytes
/
Demo4.java
File metadata and controls
30 lines (28 loc) · 956 Bytes
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
class Student {
String name;
int section;
String rollnum;
Student(){
name="Zobiya jumani";
System.out.println(" Name is: " + name);
section= 01;
System.out.println("section is :" + section);
rollnum = "21sw140"; System.out.println("RollNUmber is :" + rollnum); }
// we also make overloading Constructor which is have no return type
Student(String n, int s, String rollnu){
name=n;
section=s;
rollnum=rollnu;
System.out.println("Overloading Constructor is Called");
System.out.println(" Name is: " + name);
System.out.println("section is :" + section);
System.out.println("RollNUmber is :" + rollnum);
}
}
public class Demo4{
public static void main(String args[]){
Student s1=new Student();
System.out.println(" ");
Student s2=new Student("Sawera",01,"21sw129");
}
}