Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract class and interface

 
Pankaj Wakchaure
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me all the differences between abstract classes and interfaces ?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"pankajspace pankajspace",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pankajspace pankajspace:
Can anybody tell me all the differences between abstract classes and interfaces ?


I don't think so. You are welcome to search this forum for previous discussions though, you may find them useful. Trying to repeat old conversations is not time well spent.

Dave
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Welcome to JavaRanch.
This topic is already discussed a lot of times, so I think that you will get a link to the latest discussion.
But in short I would like to say that interfaces declare only what needs to be done, but abstract classes can tell partially how it can be done.

This should five you a hint but you'll come to know more about it later.

And I think that your name does not follow the naming conventions followed here. Please check it. You will get a message saying do from one of the senior members.

Hope this helps
 
B Sriganesh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another difference is that in a interface the members are by default public ,static and final which is not the case in an abstract class...
 
B Sriganesh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another difference is that in an interface the members are by default public ,static and final which is not the case in an abstract class...
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another difference is that in a interface the members are by default public ,static and final


This is true of data member in an interface which means that you cannot have any instance variables in interfaces but only constants -- even if the declaration looks like an instance variable, it is implicitly public static and final meaning that all data members of interfaces are public constants.

Method members, on the other hand, are implicitly public abstract and not ever static. Methods of interfaces cannot be static because methods of interfaces must be overriden, since they are abstract, and static methods cannot be overriden but only redefined.

Kaydell
[ June 24, 2007: Message edited by: Kaydell Leavitt ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic