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

Java Question on Interface and classes

 
srinivasa Avvaru
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose i have a variable called i is in interface and in Abstract class .suppose my class extends that class and implements the interface.Then which i values it takes?or it gives Complie or run time error?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

coming to your question , what is your opinion about it?
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you correctly, then the reference in ambiguous and your class wont compile.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin's right; the following little example proves it:
If you move the "implements Interface" to class Abstract then it will compile because Abstract's i will shadow Interface's i:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic