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{}
Question
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{}
Solution
Chương trình là đúng.
Lớp B đã triển khai phương thức aMethod() từ giao diện A. Lớp C kế thừa từ lớp B và triển khai giao diện A, nhưng không cần phải triển khai lại phương thức aMethod() vì lớp B đã làm điều đó.
Similar Questions
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
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{}
Which of the following is an example of achieving multiple inheritance in Java?Marks : 1Class A extends Class B and implements Interface CClass A extends Class B and Class CClass A implements Interface B and Interface CClass A extends Class B, and Class B implements Interface
ect the correct answerWhich of the following is the correct way of implementing an interface A by class B?
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.
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.