Overview
In this exercise, we will create a simple class containing a few attributes and methods. We will instantiate the class and practice using the methods and accessing the attributes.
Task 1
Create a new Java project - call it EmployeeManagement.
Create a new file - make sure you select
Java Class
and name it Employee.Within the braces of the class, create attributes to hold the employee’s first name, last name, their department and employee ID (you can assume it will be a whole number).
Still within the braces of the class, create a method that would return the employee’s full name (hint: concatenate first and last name).
Create another method (call it
introduction
) that will print out the employee's details - their ID, their department, and their full name.
Task 2
In the same project, create a new file - again select
Java class
and call it EmployeeApplication.Within the braces of the created class, type in
psvm
letters and accept the suggestion - it will create amain
method for you.Within the main method, create two employees. Access the attributes directly and assign them their names, IDs and their department information.
Let each employee introduce themselves - invoke the
introduction
method on each object.