-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEg1.java
More file actions
33 lines (26 loc) · 774 Bytes
/
Copy pathEg1.java
File metadata and controls
33 lines (26 loc) · 774 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
30
31
32
33
package oop.classesobjects;
class student{ //using another class
int id;
String name;
// student(){ //using constrctor
// id =10;
// name = "aditya";
// }
student(int n){ //using parameterize constrctor
id = n;
name = "aditya";
}
}
public class Eg1 {
// int id; // inside the main class
// String name;
public static void main(String[] args) {
// Eg1 m = new Eg1(); // inside the main class
// student m = new student(); // using another class
// m.id = 10; // inside the main class
// m.name = "java";
student m = new student(10);
System.out.println(m.id);
System.out.println(m.name);
}
}