-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathj37CreateClass.java
More file actions
39 lines (29 loc) · 1.01 KB
/
j37CreateClass.java
File metadata and controls
39 lines (29 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
class Hello{
// this is class remember we donot add pub;lic in initialixzing any class
int id;
String name;
int Salary;
// create metheod inside the Class
public void PrintDetails(){
System.err.printf("\nName is [%s] and Id is [%d]\n" ,name , id);
}
// Return Salary Function
public int ReturnSalary(){
//System.out.println(Salary);
return Salary;
}
}
public class j37CreateClass {
public static void main(String[] args){
System.out.println("Initialize Custom Class Hello");
Hello Ved = new Hello();
// Setting Attributes
Ved.id = 559;
Ved.Salary = 150000;
Ved.name = "Ved Prakash Gupta";
Ved.PrintDetails(); // metheod in custom class
//System.out.printf("Name is [%s] and Id is [%d]" ,Ved.name , Ved.id);
int Ved_sal = Ved.ReturnSalary(); //calling metheod avail in HEllo class
System.err.println("Ved Salary is : "+Ved_sal);
}
}