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 33 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
Gracias!


ghepp

  • Member
  • Posts: 361
Reply 3 on: Yesterday
Excellent

 

Did you know?

Pink eye is a term that refers to conjunctivitis, which is inflammation of the thin, clear membrane (conjunctiva) over the white part of the eye (sclera). It may be triggered by a virus, bacteria, or foreign body in the eye. Antibiotic eye drops alleviate bacterial conjunctivitis, and antihistamine allergy pills or eye drops help control allergic conjunctivitis symptoms.

Did you know?

Since 1988, the CDC has reported a 99% reduction in bacterial meningitis caused by Haemophilus influenzae, due to the introduction of the vaccine against it.

Did you know?

When intravenous medications are involved in adverse drug events, their harmful effects may occur more rapidly, and be more severe than errors with oral medications. This is due to the direct administration into the bloodstream.

Did you know?

Pubic lice (crabs) are usually spread through sexual contact. You cannot catch them by using a public toilet.

Did you know?

The tallest man ever known was Robert Wadlow, an American, who reached the height of 8 feet 11 inches. He died at age 26 years from an infection caused by the immense weight of his body (491 pounds) and the stress on his leg bones and muscles.

For a complete list of videos, visit our video library