In: Computer Science
Consider the following interface:
public interface Car{
public String getMake();
public void setMake();
public void honk();
public void crash();
public void drive();
}
public interface Boat{
public String getMake ();
public void setMake ();
public void blast_horn();
public void sink();
public void move();
}
1. Create a concrete FamilyCar class from the Car interface.
ANSWER : HERE IS THE ANSWER FOR YOUR QUESTION:
----------------------------------------------------------------------------------------------------------------
CODE:
import java.util.*;
interface Car{
public String getMake();
public void setMake();
public void honk();
public void crash();
public void drive();
}
interface Boat{
public String getMake ();
public void setMake ();
public void blast_horn();
public void sink();
public void move();
}
//FamilyCar class
class FamilyCar
{
//getmake method
public String getMake()
{
return "I am in getMake";
}
//setmake method
public void setMake()
{
System.out.println("I am in setMake ");
}
//honk method
public void honk()
{
System.out.println("peeepeeeep......i am coming ");
}
//crash method
public void crash()
{
System.out.println("Oh my good !!! almost got crashed ");
}
//drive method
public void drive()
{
System.out.println("lets go the drive now .. i am in drive
method");
}
}
public class Main
{
public static void main(String[] args) {
FamilyCar car= new
FamilyCar();
System.outcar.getMake();
car.setMake();
car.honk();
car.drive();
car.crash();
}
}
----------------------------------------------------------------------------------------------------------------
SNIPPET:
----------------------------------------------------------------------------------------------------------------
OUTPUT:
----------------------------------------------------------------------------------------------------------------
I hope this would help you out.
If you like my answer , please upvote
If you have any doubt, you can provide comment /feedback below the answer
Thanks