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

How to sort double array in java?

588


What are the elements of java?

563


Is string a datatype?

550


Difference between collection, collection and collections in java?

568


How do you compare arrays in java?

505






What is java util list?

489


How do I compare two strings in word in java?

541


What is function and method in java?

525


How can constructor chaining be done by using the super keyword?

619


how a programmer confirms that the data submitted has been succesfully inserted into the database(either oracle or my sql).. How a programmer confirm if there is any problem with the program he wrote for insertion... ANS:--- >executeupdate method is having boolean return type, if anything goes wrong in data insertion or data updation, it would return false. otherwise, if it successfully inserts data into the database, it would return true NOW HOW TO I CHECK IN MY DURING EXECUTION WHETHER IT RETURNS TRUE OR FALSE... WELL IT WILL DISPLAY ANY MESSAGE OR NOT

1852


What is difference between adapter class and listener?

501


Define max and min heap, also the search time of heap.

591


What is an anonymous class in java?

548


What are the advantages of exception handling in java?

650


What is the difference between jvm and jre? What is an interface?

553