Question

In: Computer Science

Consider the following interface: public interface Car{ public String getMake(); public void setMake(); public void honk();...

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.

Solutions

Expert Solution

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


Related Solutions

Finish the following java question: Consider the following interface: interface Duty { public String getDuty(); }...
Finish the following java question: Consider the following interface: interface Duty { public String getDuty(); } Write a class called Student which implements Duty. Class Student adds 1 data field, id, and 2 methods, getId and setId, along with a 1-argument constructor. The duty of a Student is to study 40 hours a week. Write a class called Professor which implements Duty. Class Professor adds 1 data field, name, and 2 methods, getName and setName, along with a 1-argument constructor....
Consider this program: public class Main { public static void main(String[] args) { String s1 =...
Consider this program: public class Main { public static void main(String[] args) { String s1 = "hello"; String s2 = "hello"; String s3 = new String("hello"); System.out.println(s1 == s2); System.out.println(s2 == s3); System.out.println(s2.equals(s3)); } } When we run the program, the output is: true false true Explain why this is the output, using words and/or pictures.
java: Given the definitions: public interface ActionListener { public void actionPerformed(ActionEvent e); } public JTextField {...
java: Given the definitions: public interface ActionListener { public void actionPerformed(ActionEvent e); } public JTextField { public JTextField(){} public void setText(String text) {} public String getText() {} } Write the code to create a JButton on the South of the window and a JTextField on the North. The first time you click on the button, it should print out “hello!” on the JTextField. For the second time, should show “hello!hello!”. For the third time, should show “hello!hello!hello!”.
Study the following class definition: class Car { public: Car(double speed); void start(); void accelerate(double speed);...
Study the following class definition: class Car { public: Car(double speed); void start(); void accelerate(double speed); void stop(); double get_speed() const; private: double speed; }; Which of the following options would make logical sense in the definition of the void accelerate(double speed)function? Group of answer choices this->speed = this->speed; this->speed = speed; this.speed = speed; speed1 = this->speed; Flag this Question Question 131 pts The Point class has a public function called display_point(). What is the correct way of calling...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point = new Point(10, 5);       Circle circle = new Circle(10.5, 20, 19);       Cylinder cylinder = new Cylinder(12, 3.6, 20, 20);                     System.out.println("Point");       System.out.println(point.toString()) ;       System.out.println("Circle");       System.out.println(circle.toString());       System.out.println("Cylinder");       System.out.println(cylinder.toString());       } } You will get the following result once you execute the TestDriver.java (after compiling it) Point (10, 5) Circle Center = (20, 19); Radius = 10.5 Cylinder Center = (20, 20); Radius = 3.6; Height...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point = new Point(10, 5);       Circle circle = new Circle(10.5, 20, 19);       Cylinder cylinder = new Cylinder(12, 3.6, 20, 20);                     System.out.println("Point");       System.out.println(point.toString()) ;       System.out.println("Circle");       System.out.println(circle.toString());       System.out.println("Cylinder");       System.out.println(cylinder.toString());       } } You will get the following result once you execute the TestDriver.java (after compiling it) Point (10, 5) Circle Center = (20, 19); Radius = 10.5 Cylinder Center = (20, 20); Radius = 3.6; Height...
public class OOPExercises {     public static void main(String[] args) {         A objA = new...
public class OOPExercises {     public static void main(String[] args) {         A objA = new A();         B objB = new B();         System.out.println("in main(): ");         System.out.println("objA.a = "+objA.getA());         System.out.println("objB.b = "+objB.getB());         objA.setA (222);         objB.setB (333.33);       System.out.println("objA.a = "+objA.getA());         System.out.println("objB.b = "+objB.getB());     } } Output: public class A {     int a = 100;     public A() {         System.out.println("in the constructor of class A: ");         System.out.println("a = "+a);         a =...
public class GreeterTest {    public static void main(String[] args)    { // create an object...
public class GreeterTest {    public static void main(String[] args)    { // create an object for Greeter class Greeter greeter = new Greeter("Jack"); // create two variables Greeter var1 = greeter; Greeter var2 = greeter; // call the sayHello method on the first Greeter variable String res1 = var1.sayHello(); System.out.println("The first reference " + res1); // Call the setName method on the secod Grreter variable var2.setName("Mike"); String res2 = var2.sayHello(); System.out.println("The second reference " + res2);    } }...
public class ArraySkills { public static void main(String[] args) { // *********************** // For each item...
public class ArraySkills { public static void main(String[] args) { // *********************** // For each item below you must code the solution. You may not use any of the // methods found in the Arrays class or the Collections classes // You must use Java's built-in Arrays. You are welcome to use the Math and/or Random class if necessary. // You MUST put your code directly beneath the comment for each item indicated. String[] myData; // 1. Instantiate the given...
public static void main(String[] args) {        Scanner input = new Scanner(System.in);        String[]...
public static void main(String[] args) {        Scanner input = new Scanner(System.in);        String[] strings = new String[100];        for (int i = 0; i < strings.length; i++) {            System.out.println("Enter Strings: stop ");            strings[i]=input.nextLine();            if(strings[i].equalsIgnoreCase("stop"))                break;        }               MaxLength(strings);//here is the error    }    public static int MaxLength(String[] array) {        int max = array[0].length();       ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT