Respuesta :
Answer:
The code to this question can be given as:
code:
public class Exercise09_04Extra //define class
{
public static void main(String[] args) //define main method
{
SimpleTime time = new SimpleTime(2,3,4);
//create object of the class
System.out.println("Hour: " + time.hour + " Minute: " + time.minute + " Second: " +time.second); //print result
}
}
class SimpleTime //define class
{
int hour,minute,second; //set three integer variable
SimpleTime( int hour, int minute, int second ) //define parameterized constructor
{
this.hour = hour;
this.minute = minute;
this.second = second;
}
}
Output:
Hour: 2 Minute: 3 Second: 4
Explanation:
In the above java code firstly we define a main class that is Exercise09_04Extra. In this class we create another class object that is SimpleTime . Then we call parameterized constructor and print the values. When we call the SimpleTime class in this class we define an integer variable that is hour, minute and second and create the parameterized constructor and pass the variable as a parameter.In this constructor we use this keyword to hold the value of the passing variable. So the output of the following code is "Hour: 2 Minute: 3 Second: 4 ".
The missing code segment is an illustration of constructors in Java.
Constructors are codes that are called, when the instance of an object is created.
The missing code segment in Java, where comments are used to explain each line is as follows:
//This defines the constructor
SimpleTime( int hour, int minute, int second ){
//The next three lines get the value of time (hours, minutes and seconds)
this.hour = hour;
this.minute = minute;
this.second = second;
}
}
Read more about similar programs at:
https://brainly.com/question/14670470