when,where and how to use abstract class and interface

Answers were Sorted based on User's Feedback



when,where and how to use abstract class and interface..

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

when,where and how to use abstract class and interface..

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

Post New Answer

More Core Java Interview Questions

Why Java is called as purely platform independent..? Explain briefly..dont Give regular answers Explain with your own example..?

8 Answers   Nokia,


What is the difference between Grid and Gridbaglayout?

0 Answers  


Is null == null in java?

0 Answers  


What does jenkins do?

0 Answers  


what value will be return by the read() method once it reaches the end-of-file? a. Throws EOException b. Return null c. Return -1 d. Read method return nothing, because it is void method

1 Answers  






Why singleton pattern is better than creating singleton class with static instance?

0 Answers  


Can singleton class be cloned?

0 Answers  


I want to run a simple hello world java (HelloWorld.java) program using a batch file. How can i run it and how to construct a batch file.

1 Answers   Infosys,


Why pass by reference is not possible in java?

0 Answers  


What do u mean by wrapper Class? What do u mean by Jvm... How do u change JVM for other OS? Or No need to Change ...? its like tricky

6 Answers   Accenture, EDS,


Can we nested try statements in java?

0 Answers  


What is the use of coding?

0 Answers  


Categories