This is an exercise question taken from Java Software Solutions: foundations of program design by Lewis & Loftus, 4th edition ; Question PP2.6 (here is a link)
As an alternative of user2004685's answer;
int seconds = 9999;
int hour = 9999 / (60 * 60); //int variables holds only integer so hour will be 2
seconds = 9999 % (60 * 60); // use modulo to take seconds without hours so it will be 2799
int minute = seconds / 60; //same as int variable so minute will be 49
seconds = seconds % 60; // modulo again to take only seconds
System.out.println(hour + ":" + minute + ":" + seconds);