• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

iterface method

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi buddy,

if giving more than one body of abstract method in interface when want to implement it in the class could it possible to define only ane abstract method and other not using in the class even keep it only body.


regards
tribhuwan soni
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tribhuwan, I'm sorry but it's hard to follow what you mean. Can you post some code to explain what it is exactly that you want to know?

In an interface, you cannot specify a body for a method. When you create a non-abstract class that implements an interface then all methods of the interface must be implemented in the class.
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I get what you're asking. I believe what you're trying to ask is whether an abstract class that implements an interface must give implementation code for all of the methods in the interface. (If this isn't right, feel free to correct me.)

The answer is no, but any class that extends the abstract class must implement the methods that the abstract class does not.

For example:



The interface A defines two methods. The abstract class B implements one of them, and the concrete class C implements the other.

Does this answer your question?
 
reply
    Bookmark Topic Watch Topic
  • New Topic