-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
51 lines (37 loc) · 1.27 KB
/
Main.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
42
43
44
45
46
47
48
49
50
51
public class Main {
public static void main(String[] args) {
// store 5 roll nos
// data of 5 students: {roll no, name, marks}
int[] rno = new int[5];
String[] name = new String[5];
float[] marks = new float[5];
Student[] students = new Student[5];
//declaring the student class
Student hemanth=new Student(22,"rach",8.6f);
Student kunal=new Student(55,"kUSHWA",55.4f);
// hemanth.name="rachapalli";
// hemanth.rno=55;
System.out.println(kunal.rno);
System.out.println(hemanth.rno);
System.out.println(hemanth.name);
System.out.println(hemanth.marks);
}
}
class Student {
int rno;
String name;
float marks=90;
//default constructor--> specifices what in class and how should it pass
Student(){
this.rno=12;
this.name="heamnth";
this.marks=95.4f;
}
// pass by value eeN
Student(int roll,String naam,float marks)
{
this.rno=roll;
this.name=naam;
this.marks=marks;
}
}