Skip to content

vnpugh/Employee-Status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Employee Status

Java Encapsulation

Learning Objective

This activity demonstrates how encapsulation is used in Java. The program will display the employee's name, employee_id, department, and full-time status (boolean = true). Two Java clases (src) were created, Main and Employee. Also, getter and setter methods are used to access the private variables.

Encapsulation is defined as the wrapping up of data (variables and methods) under a single unit. The variables of a class will be hidden from the other classes, and can only be accessed through the members of the current class. In other words, this OOP method acts as a protective shield that prevents the data from being accessed by the code outside this shield.

The Elements Needed for Encapsulation

  1. Declare the variables of a class private.
  2. Create getter and setter methods to modify your private attributes/variables.
  3. Create a separate main method to test the object.

Advantages of Encapsulation

  1. Provides code security through data hiding.
  2. Reusability.
  3. Flexibility (Read-only or Write-only).

**Intellij IDE community edition is used.

About

Java Encapsulation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages