DEV Community

Ranjith Ranjith
Ranjith Ranjith

Posted on

Day 5 (abstract )

What is abstract: class or method is complete and much be __finished later
Ex

abstract class student{
Void study();
Class physics student extends student
Void study();
System.out.println("studying in physics subject ")

What is Dynamic bonding :(method call is detarmind at run based actual object not tha reference type.

ex:
class Teacher {
void answerQuestion() {
System.out.println("Teacher check and answer.");
}

class MathTeacher extends Teacher {
void answerQuestion() {
System.out.println("Math Teacher: The answer in algebra!");
}

class EnglishTeacher extends Teacher{
void answerQuestion() {
System.out.println("English Teacher: Let's answer the poem.");
}
}

public static void main(String[] args) {
Enter fullscreen mode Exit fullscreen mode

Teacher t=newEnglishTeacher();

t.answerQuestion();  
System.out.println(english teacher check answer tha poem)      
t.answerQuestion();
 System.out.println(maths teacher answer tha algebra)
}
Enter fullscreen mode Exit fullscreen mode

}

Dynamic binding is also referred to as a run-time polymorphism. In this type of binding, the functionality of the method call is not decided at compile-time. In other words, it is not possible to decide which piece of code will be executed as a result of a method call at compile-time

Binding is a mechanism creating link between method call and method actual implementation. As per the polymorphism concept in Java, object can have many different forms. Object forms can be resolved at compile time and run time.

Top comments (0)