When we will use an Interface and Abstract class?

Answer Posted / debapriya patra

Interface:
Through interface we get the multiple inheritance
in java.And we implement interfaces to override the
abstract methods it contains.


Abstract class:

We also use abstract classes to override the
abstract methods that it contains.Otherwise the child class
will mentioned as abstract.

If we wants to prevent a class from instantiation then we
mentioned it as abstract.

Is This Answer Correct ?    25 Yes 18 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the major advantage of external iteration over internal iteration?

607


What is the purpose of tostring() method in java?

545


Which list does not allow duplicates in java?

504


What is namespace in java?

535


Does treeset use compareto?

530






Explain the inheritance?

568


Why does java have two ways to create child threads? Which way is better?

531


What are data types in programming?

544


If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?

696


What is set in java?

522


Is cout buffered?

680


Is array synchronized in java?

548


Detail discussions on JVM, memory management and garbage collector.

548


What is the use of toarray () in java?

531


Can we have multiple classes in a single file?

505