Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PEARSON Souch Quiz 9.4: Constructing Objects Using Constructors Question 3 of 3

ID: 3915458 • Letter: P

Question

PEARSON Souch Quiz 9.4: Constructing Objects Using Constructors Question 3 of 3 Worth 3 Points A class named Clock has two instance variables: hours (type int) and isTicking (type boolean). Write a constructor that takes a reference to an existing Clock object as a parameter and copies that object's instance variables to the object being created. Your task: Write a Clock constructor that makes this possible. Just write this constructor-don't write the whole class or any code outside of the class 04 A

Explanation / Answer

The code is as follows

public Clock(Clock obj)

{
hours = obj.hours;
isTicking = obj.isTicking;
}