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 different window types in sapscript?
What are the buffering types?
Name a few data dictionary objects?
Select query optimisation
A field containing quantity amounts (data type quan) must be assigned to a reference table and a reference field. Explain? : abap data dictionary
What is logical database? : abap hr
What is personnel sub are
What are the names of the function modules that will be generated upon activation of a lock object?
Can we control the sequence in which multiple implementations of a multiple use BADI are called? If yes, how?
how do you call third selection screen ?
How can you display frames (horizontal and vertical lines) in lists?
what is the purpose of BAPI BAPI_CUSTMATINFO_GETLIST What is input and output of this BAPI.
What are the advantages of abap query tool?
Type casting and error handling
how to read the standard field value in your custom program.