-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
29 lines (25 loc) · 825 Bytes
/
Copy pathMain.java
File metadata and controls
29 lines (25 loc) · 825 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
///1. Create a program where:Employee class has attributes name and salary, and a method displayInfo().Manager class inherits from Employee and has an extra attribute department.Print all details using an object of Manager.
class Employee {
String name;
double salary;
void displayInfo() {
System.out.println("Name: " + name);
System.out.println("Salary: " + salary);
}
}
class Manager extends Employee {
String department;
void displayInfo() {
super.displayInfo();
System.out.println("Department: " + department);
}
}
public class Main {
public static void main(String[] args) {
Manager m = new Manager();
m.name = "John";
m.salary = 75000;
m.department = "IT";
m.displayInfo();
}
}