Knowee
Questions
Features
Study Tools

2.Chương trình đúng hay sai ?interface A {public void aMethod();}interface B {public void bMethod();}interface C extends A,B {public void cMethod();}class D implements B {@Overridepublic void bMethod() {}}class E extends D implements C {@Overridepublic void aMethod() {}@Overridepublic void cMethod() {}}doneTrueFalse

Question

2.Chương trình đúng hay sai ?interface A {public void aMethod();}interface B {public void bMethod();}interface C extends A,B {public void cMethod();}class D implements B {@Overridepublic void bMethod() {}}class E extends D implements C {@Overridepublic void aMethod() {}@Overridepublic void cMethod() {}}doneTrueFalse

🧐 Not the exact question you are looking for?Go ask a question

Solution

Đúng. Trong Java, một interface có thể kế thừa từ nhiều interfaces khác bằng từ khóa extends. Một class có thể triển khai (implements) nhiều interfaces và kế thừa từ một class khác. Trong trường hợp này, interface C kế thừa từ A và B, class D triển khai B và class E kế thừa từ D và triển khai C. Tất cả các phương thức của interfaces đều được triển khai trong class E.

Similar Questions

Chương trình đúng hay sai ?interface A {public void aMethod();}class B implements A{@Overridepublic void aMethod() {}}class C extends B implements A{}

Which statements are true about the following code? (Choose all that apply)  1: interface HasVocalCords { 2: public abstract void makeSound(); 3: } 4: public interface CanBark extends HasVocalCords { 5: public void bark(); 6: }   *1 pointA. The CanBark interface doesn’t compile.B. A class that implements HasVocalCords must override the makeSound() method.C. A class that implements CanBark inherits both the makeSound() and bark() methods.D. A class that implements CanBark only inherits the bark() method.E. An interface cannot extend another interface.

Select the correct answerWhich of the following is the correct way of implementing an interface A by class B?Optionsclass B extends A{}class B imports A{}None of the mentionedclass B implements A{}

interface AC  {   public void onAC();   public void offAC();}interface Camera {   public boolean reverseGearStatus();}interface Bluetooth {   public void receiveCall();   public void makeCall();}interface Car   ,  ,     {   //Functions of car}public class FordCar   Car{      //Implementation of all abstract methods      //in AC, Camera, Bluetooth and Car}

ect answerWhich of the following is used for implementing inheritance through an interface?Optionsinheritedextendsusingimplements

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.