20626.

Write the definition of a class Simple . The class has no constructors , methods or instance variables
Answer.
public class Simple{ }

20627.
Write the definitions of two classes Day and Night . Both classes have no constructors , methods or instance variables .
Note: For this exercise, please do not declare your classes using the public visibility modifier.
Answer.
class Day{ }
class Night{ }

20628.
Write the definition of a class Clock . The class has no constructors and one instance variable of type int called hours .
Answer
public class Clock
{
private int hours;
}

20629.
Write the definition of a class Clock . The class has no constructors and two instance variables . One is of type int called hours and the other is of type boolean called isTicking .
Answer
public class Clock
{
private int hours;

private boolean isTicking;
}

20630.
Write the definition of a class Clock . The class has no constructors and three instance variables . One is of type int called hours , another is of type boolean called isTicking , and the last one is of type Integer called diff
Answer
public class Clock
{
private int hours;
private boolean isTicking;
private Integer diff;
}








No comments:

Post a Comment