Question: Write the necessary code to assign the value 5 to the field hour and the value 6 to the parameter hour. The purpose of this

Write the necessary code to assign the value 5 to the field hour and the value 6 to the parameter hour. The purpose of this questions is to demonstrate your understanding of using this reference in a constructor to distinguish between using the parameter hour versus using the field hour that has an identical name.

private int hour; // 0 - 23

private int minute; // 0 - 59

private int second; // 0 - 59

public void setTime( int hour, int m, int s )

{

// validate hour, minute and second

if ( (hour >= 0 && hour < 24 ) && ( m >= 0 && m < 60 ) &&

( s >= 0 && s < 60 ) )

{

hour // assign the value 5 to the field hour

hour // assign the value 6 to the parameter hour

minute = m;// implied this

second = s;

} // end if

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!