logo

Crowdly

Browser

Add to Chrome

Given the following code, what will be the output? interface Playable {     vo...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Given the following code, what will be the output?

interface Playable {

    void play();

}

class Guitar implements Playable {

    public void play() {

        System.out.println("Playing guitar");

    }

}

class Piano implements Playable {

    public void play() {

        System.out.println("Playing piano");

    }

}

public class Test {

    public static void main(String[] args) {

        Playable p = new Guitar();

        p.play();

        p = new Piano();

        p.play();

    }

}

0%
0%
0%
100%
More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome