Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

When we will use an Interface and Abstract class?

Answer Posted / mohd shakir

I think if you have basics knowledge of any OO language then you should be aware of basic definition of Interface and Abstract class.

Here I am going to explain when to use Interface and when to use Abstract class.

Abstract class:-> If you have a common functionality that is used by its subclasses then put that method in super abstract class(now you need not to define that common method in every subclass again and again) This is what you can't do with Interface(because all the methods are by default abstract).

Interface:-> If you don't have the scenario as I discussed above(in abstract class)then choose Interface.And you can also achieve multiple inheritance using Interface that is not possible in case of Abstract class.

Is This Answer Correct ?    21 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how does the run() method in runnable work? : Java thread

923


What is predicate in java?

1060


How to disable caching on back button of the browser?

1085


If an application has multiple classes in it, is it okay to have a main method in more than one class?

1013


How would you format a date in java? I.e. In the ddmmyyy format?

1380


What is a default method?

1053


Can we modify the throws clause of the superclass method while overriding it in the subclass?

1037


What is thread life cycle?

968


How do you convert string to int in java?

1079


How many digits is int32?

980


What is the difference between final, finally and finalize()?

1156


Is java good for beginners?

1013


How do I compare two strings in word in java?

991


What happens if we override private method?

972


What is purpose of find feature?

1081