What is up-casting and down casting? with example
Answers were Sorted based on User's Feedback
When the level of hierarchies are considered, it is the super class at higher level & sub class at lower level. Hence the assignment of subclass to a superclass is up casting & super to a subclass is down casting.
Is This Answer Correct ? | 15 Yes | 1 No |
The assignment of a subclass instance to a reference
variable of the type "reference to super class" is
described as a narrowing cast, because you are switching
from a more detailed view to a one with less detail. It is
also called as up-casting.
Is This Answer Correct ? | 12 Yes | 4 No |
Answer / 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 |
Urgent Openings for Professionals with 4+ yrs in SAP ABAP HR, for a Reputed CMM Level V Organization in Hyderabad
SAP ABAP Training Bangalore-Course Content Outline
When you prefer lsmw?
Explain the way(s) you find an exit(s) to a given standard sap program?
my questions are (1) how to transport a table along with its data from dev to prod/qa server? pls reply elaborately. if possible with screen shots. (2) i want to display like this :- * ** *** ****
What is a table pool?
How are exceptions handles in bapi's ?
how to copy client to client in scripts?
Explain the properties of selection screen?
Brief scenario of check table / value table?
8 Answers Accenture, Bristle Cone, IBM, Infosys, Yash Technologies,
What is repetitive structure and for which Infotype do we have
WHICH LANGUAGE IS USED TO WRITE ABAP CODING PART?