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 {
@Override
public String toString() {
return "Student";
}
}
class Person extends Object {
@Override
public String toString() {
return "Person";
}
}
}
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
c. m(new Person()) causes an error
d. m(new Object()) causes an error
You cannot pass a supertype variable to a subtype without explicit casting.
You might also like to view...
Where are server-scoped dynamic management views stored?
A. master system database B. model system database C. resource system database D. msdb system database
The type of a file can be changed
A. only by the superuser B. by no user
The method paint has one parameter of type:
(a) Shape (b) Graphics (c) Image (d) String
The type of multiplexer that divides the circuit horizontally into different light frequencies that are transmitted simultaneously across many channels is a:
a. wavelength division multiplexer b. time division multiplexer c. statistical time division multiplexer d. frequency division multiplexer e. statistical frequency division multiplexer