Answer:
class Day
{
}
class Night
{
}
Explanation:
Given
Two classes named: Day and Night
Requirement: Both classes have no constructors, methods or instance variables. should not be declared using the public visibility modifier.
The syntax to define a class in object oriented programming is
modifier class classname {
// Constructor
constructor(variablename) { ......}
// Methods
methods() { ... }
...
}
Access modifiers (or access specifiers) are keywords in object-oriented languages that set the accessibility of classes, methods, and other members. Examples are private, public, protected, etc.
Going by the syntax above to define class Day
Day
private class Day{
// Constructor
constructor(duration)
{
this.duration = duration;
}
// Methods
CalculateDate() { ... }
}
But the question states that both classes have no constructors, methods or instance variables. should not be declared using the public visibility modifier.
So, class Day will be defined as follows
class Day
{
}
It could also be declared using visibility modifiers other than public modifier. So, class Day will be defined as follows
private class Day
{
}
and
protected class Day
{
}
Similarly, class Night can be defined as follows
class Night
{
}
private class Night
{
}
and
protected class Night
{
}