b. s wrong with the following code for interface? What should be changed to make
ID: 3728546 • Letter: B
Question
b. s wrong with the following code for interface? What should be changed to make a valid interface for objects that have colors? public interface Colored private Color color; public color getColor() return colori Consider the following classes: public class Vehicle public class car extends Vehicle implements public class suv extends Car. c. Speed (...) Which of the following are legal statements? i. ii. Vehicle v = new Car(); Vehicle v = new SUV ( ); iii. Car c = new SUV(); iv. SUV s = new SUV ( ); SUV s = new Car(); Car c = new Vehicle(); v. vi. vii.Speed s new Car() viii. speed s = new SUV ( );Explanation / Answer
b) An interface should contain:
1.All abstract method declarations which are public and static by default.
2.It may contains constants.
This is the valid Interface after modifying.
public interface Colored
{
public Color getColor();
}
________________
c)
i) Legal (As Super class reference can refer to the Sub class objects)
ii)Legal
iii)Legal
iv)Legal
v)illegal
vi) illegal
vii) Legal
viii) Legal
__________________Thank you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.