-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchoolDemoConstructor.java
More file actions
42 lines (36 loc) · 1.01 KB
/
Copy pathSchoolDemoConstructor.java
File metadata and controls
42 lines (36 loc) · 1.01 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
import java.util.Scanner;
class Student{
int rollNo;
String sName,sAdd,sBranch;
Student(String n,String sAd,String br,int r){
rollNo = r;
sName = n;
sAdd = sAd;
sBranch = br;
}
String getDetails() {
return "Roll No : " + rollNo +"\nStudent Name : " + sName + "\nStudent Address : " + sAdd + "\nStudent Branch : " + sBranch;
}
}
class Display2{
void dis(Student st) {
System.out.println(st.getDetails());
}
}
public class SchoolDemoConstructor {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("Enter The Student Name : ");
String Name = s.nextLine();
System.out.println("Enter The Student Branch : ");
String Branch = s.nextLine();
System.out.println("Enter The Student Address : ");
String Add = s.nextLine();
System.out.println("Enter The Roll No");
int roll = s.nextInt();
Student st = new Student(Name,Add,Branch,roll);
st.getDetails();
Display2 d = new Display2();
d.dis(st);
}
}