By default, if you do not implement a constructor, the compiler will use an empty constructor (no parameters and no code). The following code will create an instance of the MyObject class using the default constructor. The object will have the default vauesfor all the attributes since no parameters were given.
MyObject obj = new MyObject();
Another type of constructor is one with no parameters (no-arg constructor). It is similar to the default, except you actually create this constructor. The contents of the the constructor may include anything. To call a no-arg constructor, use the same line of code as above. The constructor can look like the one below:
public MyObject() {
System.out.println("This is a no-arg constructor");
}
Lastly there is the parameterized constructor. This type of constructor takes in parameters as inputs to assign to values in the newly created object. You call a parameterized constructor as follows:
MyObject obj = new MyObject("Bob", 20);
The constructor will look like this:
public MyObject(String name, int age) {
this.name = name;
this.age = age;
}
In the constructor, the keyword "this" refers to the object, so this.name is a private global variable that is being set equal to the inputted value for name, in this case "Bob".
Hope this helps!
Answer: provide more info
Explanation:
The best and most correct answer among the choices provided by the question is the second choice. <span>Effective communication and critical thinking are examples of values. </span>I hope my answer has come to your help. God bless and have a nice day ahead!
Its the Thigh Bone. Hope this helps. =^-^=
Answer:
- def ending_time(hour, minutes, seconds, work_time):
- if((seconds + work_time) // 60 > 0):
- minutes = minutes + (seconds + work_time) // 60
- seconds = (seconds + work_time) % 60
-
- if(minutes // 60 > 0):
- hour = hour + (minutes // 60)
- minutes = minutes % 60
- else:
- seconds = seconds + work_time
-
- return str(hour) + ":" + str(minutes) + ":" + str(seconds)
-
- print(ending_time(2,30,59, 12000))
Explanation:
The solution code is written in Python 3.
Firstly create a function ending_time that takes the four required input parameters.
Next, create an if statement to check if the numerator of (seconds + work_times) divided by 60 is over zero. If so, increment the minute and reassign the remainder of the seconds to the variable (Line 2-4).
Next, create another if statement again to check if the numerator of (current minutes) divided by 60 is over zero, if so increment the hour and reassign the remainder of the minutes to the variable (Line 6-8)
Otherwise, just simply add the work_time to the current seconds
At last return the time output string (Line 12).