Could someone help me? I need a Java statement that creates the objectmysteryClo
ID: 3608908 • Letter: C
Question
Could someone help me?I need a Java statement that creates the objectmysteryClock of the clock type and initializes the instancevariable hr, min, and sec of mysteryClock to 7, 18, 39.
I think I understand how to create the object but I don'tquite follow how you initializes...
like Clock mysteryClock = new Clock(7, 18, 39) <---Would that be correct???
I need a Java statement that creates the objectmysteryClock of the clock type and initializes the instancevariable hr, min, and sec of mysteryClock to 7, 18, 39.
I think I understand how to create the object but I don'tquite follow how you initializes...
like Clock mysteryClock = new Clock(7, 18, 39) <---Would that be correct???
Explanation / Answer
Dear... mysteryClock is object of clock to initialize themembers of class clock we have two ways one is using constructorand other is direct initialization. Clock mysteryClock = new Clock(7, 18, 39) this canbe done only if we have constructor in class clock whose code is asfollows: clock(int m,int h,ints) { hr=h; min=m; sec=s; } Another way of initialization is mysteryClock.hr=7; mysteryClock.min=18; mysteryClock.sec=39; Hope this will helpyou...Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.