About class member access illustrated in fig08_03: o Test this example code and explain why the program cannot get o Make necessary changes on the test class MemberAccessTest to i.e., initialize the Timel object time with the same provided value the hour-minute-second values through the object time. o Take a screenshot of your updated code segment in the test class (not the output of the execution). o You may no do any changes on the class Timel.
// Fig. 8.3: MemberAccessTest.java
// Private members of class Time1 are not accessible.
public class MemberAccessTest {
public static void main(String[] args) {
Time1 time = new Time1(); // create and initialize Time1 object
time.hour = 7; // error: hour has private access in Time1
time.minute = 15; // error: minute has private access in Time1
time.second = 30; // error: second has private access in Time1
}
}
// Fig. 8.1: Time1.java
// Time1 class declaration maintains the time in 24-hour format.
public class Time1 {
private int hour; // 0 - 23
private int minute; // 0 - 59
private int second; // 0 - 59
// set a new time value using universal time; throw an
// exception if the hour, minute or second is invalid
public void setTime(int hour, int minute, int second) {
// validate hour, minute and second
if (hour < 0 || hour >= 24 || minute < 0 || minute >= 60 ||
second < 0 || second >= 60) {
throw new IllegalArgumentException(
"hour, minute and/or second was out of range");
}
this.hour = hour;
this.minute = minute;
this.second = second;
}
// convert to String in universal-time format (HH:MM:SS)
public String toUniversalString() {
return String.format("%02d:%02d:%02d", hour, minute, second);
}
// convert to String in standard-time format (H:MM:SS AM or PM)
public String toString() {
return String.format("%d:%02d:%02d %s",
((hour == 0 || hour == 12) ? 12 : hour % 12),
minute, second, (hour < 12 ? "AM" : "PM"));
}
}
![About class member access illustrated in fig08_03:
o Test this example code and explain why the program cannot get compiled.
o Make necessary changes on the test class MemberAccessTest to make it work,
i.e., initialize the Timel object time with the same provided values and then print
the hour-minute-second values through the object time.
o Take a screenshot of your updated code segment in the test class for submission
(not the output of the execution).
You may no do any changes on the class Timel.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F36b85914-2744-42f7-b8bd-af21a659e2ca%2Fc1d7d7a3-85f2-4fb1-b155-7c102fb9230f%2Fdaga0zqh_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)