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 22 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
YES! Correct, THANKS for helping me on my review


zacnyjessica

  • Member
  • Posts: 345
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

In 2006, a generic antinausea drug named ondansetron was approved. It is used to stop nausea and vomiting associated with surgery, chemotherapy, and radiation therapy.

Did you know?

Fatal fungal infections may be able to resist newer antifungal drugs. Globally, fungal infections are often fatal due to the lack of access to multiple antifungals, which may be required to be utilized in combination. Single antifungals may not be enough to stop a fungal infection from causing the death of a patient.

Did you know?

Earwax has antimicrobial properties that reduce the viability of bacteria and fungus in the human ear.

Did you know?

Not getting enough sleep can greatly weaken the immune system. Lack of sleep makes you more likely to catch a cold, or more difficult to fight off an infection.

Did you know?

Thyroid conditions cause a higher risk of fibromyalgia and chronic fatigue syndrome.

For a complete list of videos, visit our video library