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
How do you read files from the application server ? : abap bdc
in bdc session method. if u run the record in fore ground manually i have a 7 records but at the time of record processing first record produces the error how can u process records manually in fore ground please tell me any one knows?
Explain the different types of view?
What is the difference between leave transaction and call transaction?
What are system variable in abap?
could anyone tell me what r real time questions been asked in interviews?i am in urgent need..thanks in advance
how to modify the standard method as per your requirement
How to handle error in session method? : abap bdc
What is the company code? : sap abap hr
What are the events we use in dialog programming and explain them?
How do you document ABAP programs? Do you use program documentation menu option?
What is time constraint ? : abap hr
What is open sql?
What is the meaning of table buffer? This buffer is used by which type oftable?
What is a type-pool?