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

Author Question: Given the following code, find the compile error.public class Test { public static void ... (Read 36 times)

Yi-Chen

  • Hero Member
  • *****
  • Posts: 550
Given the following code, find the compile error.

public class Test {
public static void main(String[] args) {
m(new GraduateStudent());
m(new Student());
m(new Person());
m(new Object());
}

public static void m(Student x) {
System.out.println(x.toString());
}
}

class GraduateStudent extends Student {
}

class Student extends Person {
public String toString() {
return "Student";
}
}

class Person extends Object {
public String toString() {
return "Person";
}
}

◦ m(new Person()) causes an error
◦ m(new Student()) causes an error
◦ m(new GraduateStudent()) causes an error
◦ m(new Object()) causes an error


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by Yi-Chen on May 6, 2020

macagnavarro

  • Sr. Member
  • ****
  • Posts: 334
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 64% of students answer this correctly




Yi-Chen

  • Member
  • Posts: 550
Reply 2 on: May 6, 2020
Gracias!


juliaf

  • Member
  • Posts: 344
Reply 3 on: Yesterday
Thanks for the timely response, appreciate it

 

Did you know?

Side effects from substance abuse include nausea, dehydration, reduced productivitiy, and dependence. Though these effects usually worsen over time, the constant need for the substance often overcomes rational thinking.

Did you know?

About 3.2 billion people, nearly half the world population, are at risk for malaria. In 2015, there are about 214 million malaria cases and an estimated 438,000 malaria deaths.

Did you know?

Patients should never assume they are being given the appropriate drugs. They should make sure they know which drugs are being prescribed, and always double-check that the drugs received match the prescription.

Did you know?

The Centers for Disease Control and Prevention has released reports detailing the deaths of infants (younger than 1 year of age) who died after being given cold and cough medications. This underscores the importance of educating parents that children younger than 2 years of age should never be given over-the-counter cold and cough medications without consulting their physicians.

Did you know?

Asthma attacks and symptoms usually get started by specific triggers (such as viruses, allergies, gases, and air particles). You should talk to your doctor about these triggers and find ways to avoid or get rid of them.

For a complete list of videos, visit our video library