العودة   منتديات طلاب الجامعة العربية المفتوحة > منتدى كليات الجامعة العربية المفتوحة > منتدى تقنية المعلومات والحاسوب > M257

موضوع مغلق
 
أدوات الموضوع انواع عرض الموضوع

قديم 14-12-2011, 10:56 PM   #197
mo7ammadi mo7ammadi غير متصل
طــالب
 
الصورة الرمزية mo7ammadi

 











افتراضي رد: ☻TMA||Question 2|| FALL 2012☻


هذه إجابتي, وألله أعلم
يعني لا حدا يسبني ويدعي عليي لو طلع غير هيك
mo7ammadi غير متصل  
قديم 14-12-2011, 11:11 PM   #198
Shery Cat Shery Cat غير متصل
طالب فعال
 
الصورة الرمزية Shery Cat

 











افتراضي رد: باقي هالفقرات الكل متعطل عليها


انا كمان متعطلة فيها ومستنية حد يشرحهم



التوقيع

Shery Cat غير متصل  
قديم 14-12-2011, 11:25 PM   #199
مشكلتي طموحي مشكلتي طموحي غير متصل
طالب فعال

 









افتراضي رد: باقي هالفقرات الكل متعطل عليها


which of the instance variables of ShapesDataReader are primitive variables and
which are reference variables? (2 marks)

كلها ريفرنس فاريبل
مشكلتي طموحي غير متصل  
قديم 14-12-2011, 11:48 PM   #200
فن السعادة فن السعادة غير متصل
مشرفة سابقة
 
الصورة الرمزية فن السعادة
افتراضي رد: باقي هالفقرات الكل متعطل عليها


اقتباس:
المشاركة الأصلية كتبت بواسطة غ ـنـوة المطر ! مشاهدة المشاركة
2-Briefly discuss when object casting must be done explicitly, and when it is done automatically. Give simple examples?

explicitly: when assign object that is instance of super class to object that is instance of subclass's , we will need to do explicit casting.

automatically: when we assign an object of a subclass type to a superclass type.

(b) Do we have to override getArea()in Shape class (you may try this on
NetBeans)? Justify your answer

No we dont have to override getArea() because Shape is abstract



Q3.3: which of the instance variables of ShapesDataReader are primitive variables and
which are reference variables? (2 marks)

All the instance variable of ShapeDataReader is reference variable


هاذي هي الحلول
بس أبي منكم دعوة بظهر الغيب
+
التقييم إذا عجبكم حلي

التعديل الأخير تم بواسطة فن السعادة ; 14-12-2011 الساعة 11:49 PM سبب آخر: مستعجلة مرة



التوقيع

أَتَعلَمُ مَا هِيَ الثِقَةُ الكُبرَى !؟
قَولُهُ تَعَالَى : "وَ لَسَوفَ يُعطِيكَ رَبُّكَ فَـ تَرضَىْ". . أَتَرَى قَولَهُ سُبحَانَهْ ؟
هُوَ لَن يُعطِيكَ [ فَقَطْ ] !! هُوَ أَيضَاً وَعَدَكَ [ بِالرِضَا ] ♥♥♥
فن السعادة غير متصل  
قديم 15-12-2011, 12:15 AM   #201
khaled818 khaled818 غير متصل
طــالب

 










افتراضي رد: باقي هالفقرات الكل متعطل عليها


الحل في يونت 3 صفحه 42 و 43
اقتباس:
automatic
it is always legal to assign a reference of a subclass type to a superclass type. For
example, it is legal to write:
Privilegeduser p;
user u;
p = new privilegeduser();
u = p; // legal without a cast
this is similar to promotion with primitive types, where a primitive variable is
automatically converted to another primitive type. In this case, there is an automatic
conversion from the privilegeduser reference type to the user reference type. This
kind of automatic conversion only occurs from a subclass type to a superclass type. As
we said earlier, a privilegeduser 'is-a' user (by inheritance) so this conversion
makes sense.
Casting a subclass type to a superclass type
reference types can be cast using the same mechanism as for primitive types: The
desired type is put in parentheses in front of the expression whose type is to be
changed.
For example, the assignment shown previously can be written using a cast as follows:
U = (user) p; // explicit cast to type user
this makes explicit that u will reference a different type of object. This cast is not
required, however, because a privilegeduser object is a user already, by
inheritance.
So, after this assignment, with or without a cast, the user reference u is referring to a
privilegeduser object. This is safe because any method you invoke on a user can
also be invoked on a privilegeduser. So in fact, a user reference could reference
either a user or a privilegeduser kind of object.
This is a general principle: A reference can refer to an object of its type, or to an object of
any type below it in a class hierarchy, without the need for a cast

explicit
casting a superclass type to a subclass type
another general principle is that it is not allowed for a reference to refer to a superclass
type object. This means that it is not legal to write the following assignment statement:
P = u; // u could reference a user or privilegeduser object!
Why not? We cannot allow assignment of a user object reference to p because a user
object has no password variable or setpassword method. If p references a user
object, the setpassword method cannot be invoked on p.
In general, we cannot allow this kind of assignment because we will no longer know what
methods can be invoked on the referenced object.
However, notice that the user reference u could in fact refer to a privilegeduser
object.
Therefore, if we have additional information and are convinced that the assignment will
work, we can inform the system using the usual cast mechanism as follows:
P = (privilegeduser) u; // cast required for this assignment
the compiler will accept this, on the assumption that we have thought through the
implications. Any problems with this assignment cannot be detected until the program is
actually running. If u is referencing a privilegeduser object, this will not cause any
problems at run time and we will be able to invoke all the privilegeduser methods on
the object referenced by p. However, if our reasoning was incorrect, and u is referencing
a user object, this assignment would cause your program to crash with what is known
as a classcastexception.
There is a mechanism for determining the type of object referenced by a variable, so
that you can avoid crashing your program with this error.
The facility we have described here may seem troublesome, but in fact it allows you to
write flexible code. This feature is discussed in unit 5.

التعديل الأخير تم بواسطة khaled818 ; 15-12-2011 الساعة 12:19 AM
khaled818 غير متصل  
موضوع مغلق

مواقع النشر (المفضلة)

أدوات الموضوع
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع


الساعة الآن 04:06 PM.


Powered by vBulletin® Version 3.8.1, Copyright ©2000 - 2019, Jelsoft Enterprises Ltd. TranZ By Almuhajir
جميع المواضيع والمشاركات تعبر عن وجهة نظر أصحابها
ولا تعبر باي شكل من الاشكال عن وجهة نظر منتديات AOUA
تصميم وتطوير : التكنولوجيا الماسية