Polymorphism and Dynamic Method Lookup in Java
Polymorphism and dynamic method lookup are a powerful programming paradigm that simplifies client definitions, encourages object decoupling, and supports dynamically changing relationships between objects at runtime.
According to Liang, Ploymorphism is : “An object of a subtype can be used wherever its supertype value is required. This feature is known as polymorphism”
In above example method m(Object x) takes a parameter of object type. You can invoke it with any type of object because Object class is by default a super class and it can handle its subtype objects. In example we have 3 classes Person, Student1, and GraduateStudent, where as x can be instance of any given class and every class have its own toString method which is overrieded. Which implementation will be used is determined by JVM at runtime. This capability is known as dynamic binding.
nice article. it helped me a lot