Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what goes wrong - interface doubt

 
raja kanak
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why this is not compiling?


[HENRY: Added code tags]
[ October 27, 2006: Message edited by: Henry Wong ]
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

interface A {
aFunction();
}
interface B extends A {
bFunction();
}
public class ImpleTest implements B{
aFunction(){}
bFunction(){}
}

why this is not compiling?

First of all your methods don't have a return type.
Secondly,
The methods in an interface are by default public abstract. Now when you override a method (in our case public) you can't make it's access type less restrictive(eq from public to default in your case).

Assuming return type void :

 
raja kanak
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your clarifications.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic