Question: Java Write a class definition of a class named 'Value' with the following: a boolean instance variable named 'modified', initialized to false an integer instance

Java

Write a class definition of a class named 'Value' with the following:

  • a boolean instance variable named 'modified', initialized to false
  • an integer instance variable named 'val'
  • a constructor accepting a single parameter whose value is assigned to the instance variable 'val'
  • a method 'getVal' that returns the current value of the instance variable 'val'
  • a method 'setVal' that accepts a single parameter, assigns its value to 'val', and sets the 'modified' instance variable to true, and
  • a boolean method, 'wasModified' that returns true if setVal was ever called.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!