007-002-015

Array of Objects

Medium

Problem Description

Class Design for Object Arrays

In this problem, you will design a Student class that can be stored in an object array for batch operations.

Learning Objective: Define class fields and a constructor to create a class usable in object arrays

Specifications

  • Define a Student class
  • Include name (String) and score (int) fields
  • Define a constructor that accepts name and score
  • Fields should be package-private (no modifier) for direct access

Usage Example

Student s = new Student("Alice", 85);
System.out.println(s.name);  // Alice
System.out.println(s.score); // 85

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