Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 2 Current »

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

  1. Create a new Java project - call it EmployeeManagement.

  2. Create a new file - make sure you select Java Class and name it Employee.

  3. 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).

  4. Still within the braces of the class, create a method that would return the employee’s full name (hint: concatenate first and last name).

  5. Create another method (call it introduction) that will print out the employee's details - their ID, their department, and their full name.

Task 2

  1. In the same project, create a new file - again select Java class and call it EmployeeApplication.

  2. Within the braces of the created class, type in psvm letters and accept the suggestion - it will create a main method for you.

  3. Within the main method, create two employees. Access the attributes directly and assign them their names, IDs and their department information.

  4. Let each employee introduce themselves - invoke the introduction method on each object.

  • No labels