Which of the following would be legal statements Consider th

Which of the following would be legal statements?

Consider the following classes: public class Teacher {...} public class Lecturer extends Teacher {...} public class Professor extends Teacher {...} Which of the following would be legal statements? Teacher t = new Lecturer(); Teacher t = new Professor(); Lecturer I = new Professor(); Professor p = new Professor(); Professor p = new Teacher(); Lecturer I = new Teacher();

Solution

We can not instantiated the child object with parent object reference. But we can instantiated the parent object with child object reference.

Which of the following would be legal statements? Consider the following classes: public class Teacher {...} public class Lecturer extends Teacher {...} public

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site