What is up-casting and down casting? with example
Answer Posted / vamsi krishna srirangam
upcasting is used to acess the common methods of
subclass(which are redefined from super class) using super
class reference.
use:because of this only polymorphism is possible.
example:
lcl_truck,lcl_bus are subclasses to lcl_vehicle
vehicle_list type table of ref to lcl_vehicle.
lcl_vehicle = lcl_truck.
append lcl_vehicle to vehicle_list.
clear lcl_vehicle.
lcl_vehicle = lcl_bus.
append lcl_vehicle to vehicle_list.
clear lcl_vehicle.
now if you redefine the estimate_fuel method in each
subclass then that particular method only called because
fuel estimation is different for bus and truck.
Down-casting:
to take control back to the object that is called now.
to identify the triggered subclass object from the list of
available subclass objects.
?= means check whether the reference(path)
is same. if left hand path is equals to right hand path then
it copies the right hand path to left hand variable.
it is used to pick one from several
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What are the types of subroutines? : abap data dictionary
How to call transaction in session method without recording?
What is the difference between pnp and pnpce? : abap hr
What are the layers of data description in r/3? : abap data dictionary
What are the two ways for restricting the value range for a domain ?
Explain what is a foreign key relationship? Explain this with the help of an example.
Can anyone done BDC/LSMW/BAPI for F-02 and F-04.If yes let me know the processs
What are the attributes of the data? : abap data dictionary
How many types of data classes are there in sap?
What is retro active accounting
What is collective search help? : sap abap data dictionary
Event handling in oops
Does the table can have multiple foreign keys?
Workbench request are client dependent or client independent
What are the organizational related Infotypes