1.2. Method Call Semantic An attempt to call a method as in this form: e. m (), // where e is a representative of a class and m is a method first evaluates e to obtain the class of object whose method is being called . Then the expression for the arguments are evaluated to obtain actual parameter values المتغيرات الفعلية. This evaluation happen left to right. Next an activation record is created for the call and pushed onto the stack; the activation record contains room for the formal parameters المعاملات الشكلية of the method ( the formals are the variables declared in the method header) and any other local storage the method required. When the actual parameter are assigned to the formals , this kind of parameters passing is called "call by value" and Finally control is dispatched to the called method e.m.
Note: if the actual parameters value is a reference to an object, that reference is assigned to the formal . this means that the called procedure shares object with its caller. Furthermore, if these object are mutable, and the called procedure change their state, these changes are visible to the caller when it returns.
Example And in the main class, we define
And we call the method
The results in the Stack storage are:
Example 2
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
|