007-002-013
Object Creation: Array Management
Medium
Problem Description
Object Creation: Array Management
In this problem, you will design and implement an Employee class so that multiple instances can be managed in an array.
Learning Objective: Define a class with fields and a constructor, structured for management in object arrays
Overview
Create an Employee class for managing employee information.
Specifications
- Create an
Employeeclass - Fields:
name(String),id(int) - Constructor:
Employee(int id, String name)initializes both fields - Fields are package-private (no modifier) for direct access
Usage Example
Employee e = new Employee(101, "Alice");
System.out.println("ID: " + e.id + ", Name: " + e.name);
// Output: ID: 101, Name: Alice
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up