what is the difference between abstract class and
Interface?where we can use it in realtime projects?
Answer Posted / abilash
1)If we r having 2 classes, both classes need a method with
same business logic(definition). Then we can go for an
abstract class. In this abstract class we can define the
method with functionality. And the two classes will extend
this abstract class.
2)In other case if two different classes wants two different
functionalities with same method name , then we go for an
interface with abstract declaration of method.And the two
classes will implement the interface and override the method
with different business logic
| Is This Answer Correct ? | 31 Yes | 12 No |
Post New Answer View All Answers
Explain how to force the garbage collection in java.
What is the difference between C++ and Java and your preferences?
Explain the usage of this with constructors?
What is the destroy method?
Which category the java thread do fall in?
Explain the selection sort algorithm and state its time complexity?
Give me an example of array and linked list? Where they can be used?
Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?
what are the high-level thread states? : Java thread
What is return in java?
What is the difference between the size and capacity of a vector?
Write a program to print 15 random numbers using foreach of java 8?
Tell me a few examples of final classes defined in Java API?
What does escaping a character mean?
Can we overload destructor in java?