when,where and how to use abstract class and interface
Answers were Sorted based on User's Feedback
Answer / prapanch
if the developer wants some methods which are implemented
in the super class and some methods which will be
implementd by him then he will go for abstract class.
because in abstact class all methods need not to be abstact
in nature. but in interface all the methods must be
abstract and so the developer will not get any implemented
code from the interface. you will use interfaces when two
different teams are working for a same requirement then an
interface will act like a medium with which they can
interact and all the teams will be in line.so your team and
other team will implement the same method names but with
difffeerent implementation code.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / vinaykumar
If you want to provide your own services for methods we
use interfaces.If you want to provide your own services or
to use the services of the methods in your class then wego
for abstract classes.abstract class is partially implemented
and partially unimplemented class where as interface is
completely unimplemented.both of the objects can not be
created.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is final variable?
What is an inner class in java?
what is collections in java?
What is Java Classloader?
1 Answers Phantom Technologies,
Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.
Which package is used for pattern matching with regular expressions?
Explain thread in java?
What is a boolean expression in java?
Does a class inherit the constructor of its super class?if it does, how can you hide that constructor? if it doesnot how can you call it from the sub class?
Is finalize() similar to a destructor?
Is a string literal?
Can a java program have 2 main methods?