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’
LANGUAGE: JAVA
CHALLENGE:
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.
SOLUTION:
The Bad News: The content you are trying to access is only available to members.
The Good News: You too can be a member, simply Click Here.
Already a member? Log In Here
Posted in Java, Learn To Code