007-002-011

Object Creation: Default Values

Easy

Problem Description

Object Creation: Default Values

In this problem, you will define an Item class with three fields: String name, int count, and boolean available.

Learning Objective: Understand that object fields are initialized with default values

Overview

Define the Item class. The test harness will create objects, verify default field values, and test field assignments.

Specifications

  • Create an Item class
  • Define a String name field
  • Define an int count field
  • Define a boolean available field
  • Fields should be package-private (no access modifier)

Default Value Rules

  • String: null
  • int: 0
  • boolean: false

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