-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
33 lines (33 loc) · 871 Bytes
/
Employee.java
File metadata and controls
33 lines (33 loc) · 871 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
import java.util.*; // import java.util.Scanner;
public class Employee
{
public String name;
public int age;
// parameterized constructor
public Employee(String name,int age)
{
this.name = name;
this.age = age;
}
public Employee()
{
this.name = "William";
this.age = 28;
}
public void show()
{
System.out.println("Name of Employee:"+ this.name);
System.out.println("Age of Employee:"+ this.age);
}
public static void main (String args[])
{
Employee e=new Employee();
Scanner sc=new Scanner(System.in);
System.out.println("Enter the name of Employee");
String name=sc.nextLine();
System.out.println("Enter the Age: ");
int age=sc.nextInt();
new Employee(name, age).show();
new Employee().show();
}
}