85.0k views
1 vote
Write the definition of a class Clock. The class has no constructors and three instance variables. One is of type int called hours, initialized to 12, another is of type boolean called isTicking, initialized to true, and the last one is of type Integer called diff, initialized to 5.

A) Public class Clock {
B) Private int hours = 12;
C) Private boolean isTicking = true;
D) Private Integer diff = 5;

User Bertolami
by
4.7k points

1 Answer

5 votes

Answer:

Following are the program definition in the Java Programming Language.

//define a class

public class Clock

{

//set integer type variable and initialize value

private int hours=12;

//set boolean type variable and initialize value

private boolean isTicking=true;

//set integer type variable and initialize value

private Integer diff=5;

}

Step-by-step explanation:

Following are the description of Code.

  • Firstly define a class "Clock" with the "private" access modifier.
  • Then, set the integer data type variable "hours" with the "private" access modifier and assign value 12 in that class.
  • After that, set the boolean data type variable "isTicking" with the "private" access modifier and assign value "true".
  • Finally set Integer class variable "diff" with the the private access modifier and assign value 5.
User Mark Levison
by
5.0k points