• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

abstract vs interface

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abstract class statisfies all the needs of interface.i.e

interface Test1
{
void method1();
void method2();
......
}
can be replaced with the following abstract calss

abstract class Test{
abstract public void method1();
abstract public void method2();
....
}

so then can any tell me what's the use of interface. thanks in advance
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go thru the folloing URL:

http://mindprod.com/jgloss/interfacevsabstract.html

Sree Nivas
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and simply use the search function here.

It seems every time a Java course begins at a school somewhere and they get to inheritance half the students post this exact same questions (with slightly different wording) here and in every other Java forum worldwide.
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case it helps...

I'd start to design a code solution using interfaces, then change an interface into an abstract class if I could see particular benefits. If an abstract class just as easily be an interface - make it an interface. It'll make your code more reusable / flexible in the future.

Regards, Louise
 
sarada konda
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know the interface has one major adv over abstract class i.e
interface -> a class can implement more than one interface
abstract class -> a class can extend only one abstract class
apart from this is there any major advantage of using interface instead of abstract class.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic