Consider the following code snippet, public Interface Measurable {double getMeas
ID: 3815002 • Letter: C
Question
Consider the following code snippet, public Interface Measurable {double getMeasure(); public class Coin implements Measurable public double getKeaaure() return value;}} public class DataSet {public void add {} {} public class BankAccount {public void add {} {}} Which of the following statements is correct? Explain your answer. Coin = new Coin(0.1, "dime"); Measurable x - dime; Coin dime = new Coint (0.l, -dime"); Dataset x = dime; Coin dime = new Coin (0.l, = dime"); DataSet x = = (Measureable) dime; d) Coin dime = new Coint (0.l, "dime"); BankAccount x = dime;Explanation / Answer
a)
Coin dime = new Coin(0.1, "dime");
Measurable x = dime;
This is VALID, because Coin class is implementer of Measurable iterface
So Measurable can hold the object of type Coin
Others are not valid as Coin class is not child class or implementer class of
Dataset and BankAccount
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.