-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram67.java
More file actions
54 lines (40 loc) · 1.31 KB
/
Copy pathprogram67.java
File metadata and controls
54 lines (40 loc) · 1.31 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
/*
Program 1: Student Information System
Aim
To study the concepts of Classes & Objects, Object References, Methods, Passing
Arguments, and the this Keyword in Java.
Problem Statement
Create a Student class having the following data members:
• Roll Number
• Name
• Marks
Use methods to accept and display the details of two students. Use the this keyword to
differentiate instance variables from local variables.
*/
class Student{
int rollNo;
String name;
double marks;
void acceptData(int rollNo,String name, double marks){
this.rollNo = rollNo;
this.name = name;
this.marks = marks;
}
void displayData(){
System.out.println("Student Details : ");
System.out.println("Name : " + name);
System.out.println("Roll No. : " + rollNo);
System.out.println("Marks : " + marks);
System.out.println("_______________________________");
}
}
public class program67{
public static void main(String[] args) {
Student s1 = new Student();
Student s2 = new Student();
s1.acceptData(066, "Shalabh Suman", 82.88);
s2.acceptData(067, "Student 2", 4.2);
s1.displayData();
s2.displayData();
}
}