Employee.java - Write a Java program which creates a class named 'Employee' having the following members: Name, Age, Phone number, Address, Salary. It also has a method named 'print-Salary( )' which prints the salary of the Employee. Two classes 'Officer' and 'Manager' inherits the 'Employee' class. The 'Officer' and 'Manager' classes have data members 'specialization' and 'department' respectively. Now, assign name, age, phone number, address and salary to an officer and a manager by making an object of both of these classes and print the same.
Officer
Enter the Name :
Akku
Enter the Address :
Sky High
Enter the Phone_Number :
Enter the Age :
20
Enter the Salary :
500000
Enter the specialization
CS
Manager
Enter the Name :
Sara
Enter the Address :
Bottom High
Enter the Phone_Number :
Enter the Age :
18
Enter the Salary :
8000000
Enter the department
IT
Officer
Name : Akku
Age : 20
Address : Sky
Phone_Number : High
Salary : 500000
Specialization : CS
Manager
Name : Sara
Age : 18
Address : Bottom
Phone_Number : High
Salary : 8000000
Department IT
sides_of_shape.java - Write a java program to create an abstract class named Shape that contains an empty method named numberOfSides( ). Provide three classes named Rectangle, Triangle and Hexagon such that each one of the classes extends the class Shape. Each one of the classes contains only the method numberOfSides( ) that shows the number of sides in the given geometrical structures.
Rectangle has 4 sides.
Triangle has 3 sides.
Hexagon has 6 sides.
Garbage.java - Write a Java program to demonstrate the use of garbage collector.
Enter the Name of Student :
Akash
Enter the Roll No :
09
Enter Phone Number :
123456
Details
The Name of Student is Akash
Roll No is 9
Phone Number is 123456
Garbage of Object Collected
engineer_employee.java - Write two Java classes Employee and Engineer. Engineer should inherit from Employee class. Employee class to have two methods display() and calcSalary(). Write a program to display the engineer salary and to display from Employee class using a single object instantiation (i.e., only one object creation is allowed).
a. display() only prints the name of the class and does not return any value. Ex. “Name of class is Employee.”
b. calcSalary() in Employee displays “Salary of employee is 10000” and calcSalary() in Engineer displays “Salary of employee is 20000.”
Name of class is Employee.
Salary of Employee is 10000
Salary of Engineer is 20000