• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface inheritance

 
Gaurav Pavan Kumar Jain
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. public interface A {
2. String DEFAULT_GREETING = �Hello World�;
3. public void method1();
4. }
A programmer wants to create an interface called B that has A as its
parent. Which interface declaration is correct?
A. public interface B extends A { }
B. public interface B implements A {}
C. public interface B instanceOf A {}
D. public interface B inheritsFrom A { }

Answer is B but i think it should be A
 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The answer for this cannot be B. Interface implements interface is never legal.
implements
keyword itself says that the class which is implementing the interface will give the implementtion for all the methods in the interface(unless the class is a abstract class).
 
rex tony
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav Pavan Kumar Jain
The answer is Only "A"
<Interface> extends <interface>
<class> implements <interface>
you've to see the JSL 9.1.1
B is illegal
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!