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
Is main window mandatory in smartforms?
What is meant by authorization? Did you ever work on it? : sap abap hr
Explain how to create any functions?
What is size category?
How we format the data before writing a statement in the report?
Can a transparent table exist in data dictionary but not in the database physically? : abap data dictionary
Explain what is the step-by-step process to create a table in data dictionary?
Which objects are independent transport objects?
What are lock objects?
What is the disadvantage of a call by reference?
What are the advantages and disadvantages of different types of bdc's?
Define database layer?
How many main windows will be there in a page window?
What are the uses of the information in the data dictionary? : abap data dictionary
What are user exits? What is involved in writing them? What precations are needed?