What is the difference between Abstract Class and Interface
Answer Posted / vikrant
Nothing stops you using interfaces and abstract classes
interchangeably. The difference is in the ideology where to
use it.
An abstract class is to be used when one needs to create a
hierarchy. e.g. Poodle, Pointer and Chihuahua are all breeds
breeds of dogs, they have some common characteristics as
dogs and some special characteristics of its breed. so all
breeds (Poodle, Pointer and Chihuahua classes) will inherit
from the Dog class.
Interface on the other hand is just a contract. The
implementing classes need not be related. Say a 3-D figure.
Sphere, Cone, Cylinder are all 3-D shapes they have nothing
in common apart from being 3-D figures. Each will have their
own equation for calculating area, perimeter, volume. All
need to specify in Shapes interface is that the implementing
class must be able to calculate area, perimeter, volume.
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is use of arraylist in java?
What is the difference between length and size in java?
What is class and object in java?
What is the difference between yielding and sleeping?
You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain
What is an object in java and how is it created?
For ease of programming you can consider the maze as a 2D array with colors represented by below integer and characters (in capital letters). • B - Black • W -White • G- Green • R- Red R B W B W W W W W W B W B B W W W W W W W B W B W W W B W W W W B B W W W B W W W B W W B B B B W B W B W W B W W W B W W W B B B W W B W W W B W W B W B W W W B W B W W W W B B W W W W B W W W W W G Shortest Route Problem: • Solution that finds the shortest Route between Red and Green White will have 1 Weight. Red and Green carry no weights. Shortest path is the path with less weight when you add up the weights in the path.
Is arraylist sorted in java?
What is a numeric digit?
Objects or references which of them gets garbage collected?
What is difference between static and abstract class?
What do you mean by of string::valueof expression in java 8?
What is the use of optional ?
What is the protected method modifier?
In a container there are 5 components. I want to display all the component names, how will you do that?