This topic contains a solution. Click here to go to the answer

Author Question: Why does the following class have a syntax error?import java.applet.*;public class Test extends ... (Read 46 times)

s.tung

  • Hero Member
  • *****
  • Posts: 577
Why does the following class have a syntax error?

import java.applet.*;

public class Test extends Applet implements Runnable {
public void init() throws InterruptedException {
Thread t = new Thread(this);
t.sleep(1000);
}

public synchronized void run() {
}
}

◦ You cannot put the keyword synchronized in the run() method.
◦ The sleep() method is not invoked correctly; it should be invoked as Thread.sleep(1000).
◦ The sleep() method should be put in the try-catch block. This is the only reason for the compilation failure.
◦ The init() method is defined in the Applet class, and it is overridden incorrectly because it cannot claim exceptions in the subclass.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by s.tung on May 6, 2020

mk6555

  • Sr. Member
  • ****
  • Posts: 310
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 39% of students answer this correctly




s.tung

  • Member
  • Posts: 577
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


Laurenleakan

  • Member
  • Posts: 309
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

HIV testing reach is still limited. An estimated 40% of people with HIV (more than 14 million) remain undiagnosed and do not know their infection status.

Did you know?

Hyperthyroidism leads to an increased rate of metabolism and affects about 1% of women but only 0.1% of men. For most people, this increased metabolic rate causes the thyroid gland to become enlarged (known as a goiter).

Did you know?

Between 1999 and 2012, American adults with high total cholesterol decreased from 18.3% to 12.9%

Did you know?

The first war in which wide-scale use of anesthetics occurred was the Civil War, and 80% of all wounds were in the extremities.

Did you know?

Patients who cannot swallow may receive nutrition via a parenteral route—usually, a catheter is inserted through the chest into a large vein going into the heart.

For a complete list of videos, visit our video library