Question
Answer the following questions based on the following classes: public interface Washable { void wash(); } public abstract class Vehicle implements Washable { private String
Answer the following questions based on the following classes:
public interface Washable
{
void wash();
}
public abstract class Vehicle implements Washable
{
private String name;
public String getName()
{
return name;
}
}
public class Car extends Vehicle
{
@Override
public void wash()
{
// some super special code here
}
void boolean premiumGas()
{
// more code
}
)
What is the name of the interface?
Washable
Is the interface a functional interface? Why or why not?
Yes, any interface containing only one abstract method is known as a functional interface.
What is the name of the superclass?
Vehicle
What is the name of the subclass?
Car
Why did we have to put abstract on the Vehicle class?
Is Car also abstract? Why or why not?
Declare a variable of type Vehicle, but assign it an object of type Car
If you have the variable: Vehicle v, but you know it hold a Car reference, write a line that will print the value returned by calling premiumGas
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started