When we r go to abstract class and when we go to Interface?
i have confusion this question while in interview plz clarify

Answers were Sorted based on User's Feedback



When we r go to abstract class and when we go to Interface? i have confusion this question while ..

Answer / atul

multiple inheritence is not possible so we use interface
instead of it.when we declare interface then inside declare
all methods is by default abstract, data member is by
default final & static .final means there is must
Initialization at declare time otherwise inside first
constructor call.
thats it...

Is This Answer Correct ?    11 Yes 0 No

When we r go to abstract class and when we go to Interface? i have confusion this question while ..

Answer / nani

If we want share some common features with all we can go for
abstract otherwise we can prefer interface .
i will give good example to understand easily.
Ex: wholesaler has books and stationary(pens & papers)

supplier1 ask for X class books and Pens
Supplier2 ask for X class books and papers.

here both suppliers asking same standard books and different
stationary items.suppose we can take it as by methods, here
here books methods are common to shared by both suppliers.so
book method is non abstract class. so here we can prefer
abstract.



supplier1 ask for X class books and Pens
Supplier2 ask for V class books and papers.

here both suppliers asking different standard books and
different stationary items.

Is This Answer Correct ?    5 Yes 0 No

When we r go to abstract class and when we go to Interface? i have confusion this question while ..

Answer / arjun

In interface we can writer interface keyword and abstract we can write abstract class
In interface we can write constructor but abstract no
In interface we can forcely implement all methods but abstract no
In interface all variables public static final we can not change but abstract not

Is This Answer Correct ?    0 Yes 7 No

Post New Answer

More Core Java Interview Questions

What is finalize() function in java?

0 Answers  


Can a variable be local and static at the same time?

0 Answers  


What is a lightweight component?

0 Answers  


how to convert mm/dd/yy to dd/mm/yy using collections in java.

4 Answers   Bosch,


Does java allow overriding static methods ?

0 Answers  






What is downcasting?

0 Answers  


List the three steps for creating an object for a class?

0 Answers  


what is the need of the Ajax?

5 Answers   iFlex,


What is application system?

0 Answers  


which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

6 Answers   HP, SparkTG,


What is the purpose of the main method?

0 Answers  


What is meant by oops concept in java?

0 Answers  


Categories