61.0k views
1 vote
Which of the following statements are true?

(Choose more than one)

A. m(new GraduateStudent()) causes an error.
B. m(new Student()) causes an error.
C. m(new Person()) causes an error.
D. m(new Object()) causes an error.

User Danbal
by
7.7k points

1 Answer

4 votes

Final answer:

The question addresses an issue with method calls in object-oriented programming, focusing on which method calls would cause an error based on parameter type compatibility and inheritance.

Step-by-step explanation:

The question appears to relate to a computer programming concept, probably in object-oriented programming (OOP), such as Java or C#. Errors in this context are likely linked to method calls and parameter type compatibility. In OOP, methods (functions) can be defined to accept parameters of certain types. The statement m(new GraduateStudent()) might cause an error if the method m does not accept an argument of type GraduateStudent, or any of its parent types if polymorphism is in play. This reasoning applies to other options as well.

If we assume m is a method that accepts an object of type Person as a parameter, but not objects of type Object, Student, or GraduateStudent (unless they are subclasses of Person), only m(new Person()) would not cause an error. The other calls would cause errors if the types are not compatible. Type compatibility and inheritance are crucial factors here.

.