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

interface and abstract methods.

 
SaiPrasad Jukalkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On JWhiz Labs Tips page the 16th Tip says
-----Interface methods can't be native, static, synchronized, final, private, protected or abstract. ------
but when i compile this code it compiles without giving any errors.
interface xy{
abstract void xymethod();
}
pl. kindly clear my doubts.
 
Arpana Rai
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by SaiPrasad Jukalkar:
On JWhiz Labs Tips page the 16th Tip says
-----Interface methods can't be native, static, synchronized, final, private, protected or abstract. ------
but when i compile this code it compiles without giving any errors.
interface xy{
abstract void xymethod();
}
pl. kindly clear my doubts.

Interface methods are implicitly public and abstract.so it is not a good practise to declare them abstract expilicitly though it will not give any kind of error.
regds
Arpana
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Aparna rightly pointed out, they are implicitly public and abstract. And it is incorrect to say that they can't be abstract.
- Manish
 
Siva Sivaraman
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Select the valid modifiers for Interface methods
1.abstract
2.native
3.volatile
Is this an ambiguous question?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic