How to type casting in OOPS ABAP and ABAP ?

Answer Posted / rs agarwal

1. Narrow casting

2. Wide casting

Demo on "Narrow Casting" Parent class->M1 , Child class-
>M1,M2
Attributes of super class can only be accessed.
Methods defined at Super class(M1) can only be accessed.
Methods with REDEFINED Logic(M1) will be called
Methods in child class (M2) cannot be accessed
Demo on "Wide Casting" Parent class->M1 , Child class->M1,M2
Assign address of PARENT to CHILD Class object
Methods defined at child class(M2) can also be accessed
with Parent reference.
Methods with REDEFINED Logic (M1) will be called
The cast is only possible if the object was instantiated as
the child and then it was casted to the parent object and
then back again to the child object. The child has
everything the parent has so there is no problem with this
path.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

1 . how do u design technical documentation in abap ? 2 . what u currently devloped in sap abap ?

2550


Explain the relationship between a functional area, user group, and query when developing queries using the sap query tool?

565


Which one is better joins or views and why?

617


What is netweaver???what is the relationship with ABAP?

1611


Explain data dictionary in abap?

586






What is the function of the transport system and workbench organizer?

655


What is the function module to popup contents in the internal table?

547


Is there any BAPI to retrieve list of customers and their sales areas i.e., Cust No, Distr Channel and Division for all the customers.

1568


What is a transport?

611


What are the internal tables and work area?

538


What is sequence number

1730


Explain what is sap script?

633


How to get that a secondary index is attached to a select query?

934


Can a filed occur in several field groups?

579


Explain what is step-loop? Explain all the steps?

694