0

how OOPS concept playing roles in terms of compile time and run time polymorphism.

how inheritance and encapsulation and polymorphism applied in real time application.

when and where and how to decide this oop concept fit for this like java bean,interface,abstract,etc?

3
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by java_programmer
0

There are two types of polymorphism
1. compile time polymorphism
2. run time polymorphism.

Compile time polymorphism is functions and operators overloading.
Runtime time polymorphism is done using inheritance and virtual functions.[Eg: function overriding]

0

Compile time polymorphism is as new_programmer said, method and operator overloading.
Run time polymorphism is I think program to Interface over implementation. Following example will help to clear the idea -

Interface Shape {
    void draw();
}

class Circle implements Shape {
    void draw() {
        System.out.printlbn("Drawing circle");
    }
}
class Square implements Shape {
    void draw() {
        System.out.printlbn("Drawing square");
    }
}
Class testInter {
    public static void main(String [] args) {
        Shape s;
        s = new Circle();
        s.draw(); //Calling the draw method in circle
        s = new Square();
        s.draw(); //Calling the draw method in square
        // Method of which class will be invoked determined at runtime based on the 
        //reference variable.
    }
}

There are two types of polymorphism
1. compile time polymorphism
2. run time polymorphism.

Compile time polymorphism is functions and operators overloading.
Runtime time polymorphism is done using inheritance and virtual functions.[Eg: function overriding]

Edited by java_programmer: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.