This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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