-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathMain2.java
More file actions
69 lines (58 loc) · 2.41 KB
/
Main2.java
File metadata and controls
69 lines (58 loc) · 2.41 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Student{
private String name;
private int age;
private int section;
private String rollNumber;
private String department;
public void setName(String name){ this.name=name;}
public void setAge(int age){ this.age=age;}
public void setSection(int section){ this.section=section;}
public void setRollNumber(String rollNumber) {
this.rollNumber=rollNumber;
}
public void setDepartment(String department){ this.department=department;}
public String getName(){ return name;}
public int getAge() { return age;}
public int getSection() { return section;}
public String getRollNumber() { return rollNumber;}
public String getDepartment() { return department;}
Student( String name ,int age, int section, String rollNumber, String department) {
System.out.println("Parameterizez constructor called ");
// System.out.print(" Name is : " );
// System.out.println( this.name = name);
this.name = name;
//System.out.print(" Age is : " );
// System.out.println(this.age = age);
this.age = age;
// System.out.print(" Section is : " );
//System.out.println(this.section = section);
this.section = section;
// System.out.print(" Roll number is : " );
// System.out.println(this.rollNumber = rollNumber);
this.rollNumber = rollNumber;
// System.out.print(" Department is : " );
// System.out.println(this.department = department);
this.department = department;
}
public class Runs{
}
public static void main(String[] args) {
Student str =new Student("Zobiya", 20, 01, "21sw140,","Software");
System.out.println(" Name is : " +str.getName());
System.out.println(" Age is : " +str.getAge());
System.out.println(" Section is : " +str.getSection());
System.out.println(" RollNumber is : " +str.getRollNumber());
System.out.println(" Depatment is : " +str.getDepartment());
System.out.println(" ");
str.setName("Yusra");
str.setAge(19);
str.setSection(01);
str.setRollNumber("21sw034");
str.setDepartment("Software");
System.out.println(" Name is : " +str.getName());
System.out.println(" Age is : " +str.getAge());
System.out.println(" Section is : " +str.getSection());
System.out.println(" RollNumber is : " +str.getRollNumber());
System.out.println(" Depatment is : " +str.getDepartment());
}
}