what is the ipmortants of polymorphism,whats the different between Abstract method/class and Interface?
how to decide on when to use interface over abstract?
This topic has been locked.
1 reply Latest Post - 2011-06-28T07:29:57Z by phalgunkumar
Pinned topic polymorphism
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-06-28T07:29:57Z at 2011-06-28T07:29:57Z by phalgunkumar
phalgunkumar 270003HAWF1 PostACCEPTED ANSWER
Re: polymorphism2011-06-28T07:29:57Z in response to MakhayeniPolymorphism : Showing one thing in different forms (in general wordsd). But in java we have two types of polymorphism. 1) Static(method overloading) 2) Dynamic (Method Overrriding.
Method Oveloading : With same method name we will write two or more mthods in a single class (diiferentiating type of parameters and no. of parameters).
ex: void add(int a, int b) and void add(double a, double b) etc.
Method Overriding : With same method siganture we will write one more mthod in child classes. Based on the reference it will called dynamically.
Abstarct Method : A method which is not having body, we will just declare it. Defination will be in implemented or extended class
Abstarct Class : A class which has atleast on abstract method in it.
Interface : All the methods by default abstrat and variables by defauls final.
Difeerence Between Abstract Class and Interface : We will go for Abstarct Class when we need partial implementation left to child class
We will go for Interface when we need full implementation left to implemented class