Question: You are given a Java source code (TestExam.java) with errors (syntax errors and/or logical errors, if any) below: class FinalException { private String msg; JOUW

 You are given a Java source code (TestExam.java) with errors (syntaxerrors and/or logical errors, if any) below: class FinalException { private Stringmsg; JOUW NI FinalException() { msg = new ("Check : Should beless than 5 hours "); } 8 9 10 11 12 publicString getMessage() { return msg; } } 13 14 15 16 1718 19 20 class Time private String startTime; private String endTime; 2122 23 24 25 26 public Time () {startTime=s; endTime=e; } NNN

You are given a Java source code (TestExam.java) with errors (syntax errors and/or logical errors, if any) below: class FinalException { private String msg; JOUW NI FinalException() { msg = new ("Check : Should be less than 5 hours "); } 8 9 10 11 12 public String getMessage() { return msg; } } 13 14 15 16 17 18 19 20 class Time private String startTime; private String endTime; 21 22 23 24 25 26 public Time () {startTime=s; endTime=e; } NNN 29 30 public String getStartTime() {return startTime; } public String getEndTime () {return endTime; } 31 32 33 } 34 35 class Exam 36 37 38 39 40 public Exam (Time dt) { time=dt; } 41 public abstract void print(); } 42 43 44 45 46 class Online Exam extends Exam { private int term; public Online Exam (Time dt, int t ) { super(); 47 48 49 term=t; } 50 51 52 public int getTerm () {return term; } 53 54 55 56 57 58 59 60 61 62 63 64 public void print() { System.out.println ("Online Exam : Part "+getTerm () + " will starts on " +getStartTime()+" and will end on "+ getEndTime()); } } class TakeHomeExam extends Exam private String event; public TakeHomeExam (Time dt, String t) { super(); event=t; } 65 66 67 68 69 70 public string getEvent () {return event;} 71 72 73 74 public void print() { System.out.println ("TakeHome Exam :" +getEvent()+" will starts on "+getStartTime()+" and will end on "+ getEndTime()); } } 76 77 78 79 public class TestExam public static void main (String[] args) { 80 81 82 83 84 85 Scanner input = new Scanner (System.input); System.out.println("Enter the final exam duration:" ); duration=input.nextInt(); try 86 87 88 89 { if (input>5) throws FinalException(); } finally (FinalException exp) { System.out.println (getMessage()); } 90 91 92 93 94 95 96 97 98 99 Time timel= new Time ("9.00 am","9.30 am" ); Time time2= new Time ("10.00 am","11.00 am" ); Time time3= new Time ("11.00 am","1:00 pm"); 100 101 Exam [] exm = new exm [3]; exm[0]= new Online Exam (1); exm[1] = new TakeHomeExam (" Part II : Debugging"); exm [2] = new TakeHomeExam(" Part II : Programming"); 102 103 104 105 106 for (Exam i:exm) print(); } } Based on UML class diagram given in Figure 1, debug the errors. Then, compile and run the program. The program should produce the output as shown in Figure 2 and Figure 3. Note that the text in bold indicates input entered by the user. The following are the distribution mark of the tasks: (a) Finding all errors (35 marks). (b) Program able to compile and run successfully (5 marks). () Produce the expected output (5 marks). Tine -start Time: string endTime: String - Time +Time(String, String); void *get startTime(): String getEndTine)String an(Tine) void print) : void A onlinex TakeHomeExa term int event: String + Online Exam Date, int) : void + getTern() int print(void + TakeHomeExan(Date, String) : void getEvent(): String print()void ecexception>> FinalException TestExam .main(string): void -189: string + FinalException():void + getMessage(): String Enter the final exam duration : 7 Check : Should be less than 5 hours Online Exam : Part 1 will starts on 9.00 am and will end on 9.30 am TakeHome Exam : Part II : Debugging will starts on 10.00 am and will end on 11.00 am TakeHome Exam : Part II : Programming will starts on 11.00 am and will end on 1:00 pm Figure 2: Example of output 1 Enter the final exam duration: 4 Online Exam : Part 1 will starts on 9.00 am and will end on 9.30 am TakeHome Exam : Part II : Debugging will starts on 10.00 am and will end on 11.00 am TakeHome Exam : Part II : Programming will starts on 11.00 am and will end on 1:00 pm Figure 3: Example of output 2

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!