Question: Whenever I try to compile my code, it says error: call to super must be first statement in constructor super(setTime) Can someone please help

Whenever I try to compile my code, it says "error: call to super must be first statement in constructor

super(setTime)" Can someone please help me with this, thank you!

public class CMilClock extends CClockType { private int milHours; private int milSec; public CMilClock() { this.milHours = 0; this.milSec = 0; } public CMilClock(int milHours, int milSec) { setTime(milHours, milSec); } public void setTime(int milHours, int milSec) { // TODO change the member variable values in base class and super class super(setTime); this.milHours = milHours; this.milSec = milSec; } public int getHour() { return this.milHours; } public int getStdHr() { return super.getHour(); } public void printTime(){ System.out.println(this.milHours + ":" + this.milSec); super.printTime(); } public static void main(String [] argv){ CMilClock myClock = new CMilClock(1230, 10); myClock.printTime(); CClockType youClock = new CMilClock(1230, 10); youClock.printTime(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!