when to use abstract class and when to use interface?

Answer Posted / mohit jethva

In Interfate you are restricting a user to impement each
and every method of interface so if you have a requirement
which is constantly changing so don't prefere interface.

While in Abstract Class user don't need to implement each
and every method which is not required or marked with
mustoverride.


And by using interface you can achive multiple inheritance
in C# but with Abstact class it's can't be achive

Is This Answer Correct ?    31 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does ide stand for?

525


Why scanner is used in java?

552


when to use ArrayList and when to use HashMap in webApplication.

3894


Which are different kinds of source code?

664


Convert a BST into a DLL and DLL to BST in place.

674






Can we create constructor in abstract class ?

586


What is considered an anti pattern?

531


How a string is stored in memory?

584


What is the difference between the final method and abstract method?

544


What is the symbol for line break?

612


How can you read an integer value from the keyword when the application is runtime in java? example?

627


What are triggers in DB? Explain their types. How do they work?

630


How to create com object in Java?

653


What are java threads?

623


Why is string buffer better than string ?

605