• 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

Core Java Releated Quesstion

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between the abstract class and the interface
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An Abstract class declares have at least one instance method that is declared abstract which will be implemented by the subclasses. An abstract class can have instance methods that implement a default behavior.

An Interface can only declare constants and instance methods, but cannot implement default behavior.

Hope this help...

Regards,
Shalini
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
further you can assume, an interface is a COMPLETE abstract class. :-)
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no. In interface in Java has a somewhat similar role to a pure virtual class in C++ (though there are important (mainly philosophical) differences as well).

There's no such beast as a "complete virtual" class and interfaces aren't classes (even if they compile to .class files, probably because the JVM designers didn't want to introduce yet another file type).
 
Bartender
Posts: 3913
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shalini Chandel:
An Abstract class declares have at least one instance method that is declared abstract which will be implemented by the subclasses. An abstract class can have instance methods that implement a default behavior.



Wrong.

Abstract class :

1. May have no methods at all:



2. May have no abstract methods (all methods are concrete):



regards,
MZ
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen Wenting:
no. In interface in Java has a somewhat similar role to a pure virtual class in C++ (though there are important (mainly philosophical) differences as well).

There's no such beast as a "complete virtual" class and interfaces aren't classes (even if they compile to .class files, probably because the JVM designers didn't want to introduce yet another file type).



interfaces aren't classes? Agreed Wenting. But I said you can assume them to be COMPLETE abstract classes. I dont want to talk of C++ or terms like "virtual" in an SCJP forum, the following link would speak what I meant...

http://www.google.co.in/search?biw=800&hl=en&q=%22interfaces+are+abstract+classes%22+java&btnG=Google+Search&meta=
[ June 28, 2005: Message edited by: Akhil Trivedi ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic