Question
Write a Java class Clock for dealing with the day time represented by hours, minutes, and seconds. Your class must have the following features: i.
Write a Java class Clock for dealing with the day time represented by hours, minutes, and seconds. Your class must have the following features:
i. Three instance variables for the hours, minutes, and seconds. (2 marks)
ii. Write default constructors for class Clock. (1 marks)
iii. Write a constructor with three parameters: hours, minutes, and seconds. This constructor will get hour, minutes and second passed by main class. (6 marks)
iv. Create an object to call default constructor and constructor with value as below: Hour = 3 Minutes = 40 Second = 20 (4 marks)
(b) Based on question (a), explain benefit of using these OOP concept in your work.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started