انتقل إلى المحتوى
أمين أبوزيد
BEG-009

المتغيرات وأنواع البيانات

  • 7 درس
  • 83 دقيقة قراءة
  • 4 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • الأنواع الأولية (Primitives)
  • الأنواع المرجعية
  • المتغيرات
  • القيم الحرفية (literals)
  • الثوابت
  • اصطلاحات التسمية
  • تحويل الأنواع

تعلّم أولًا

83 دقيقة قراءة · 4 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Declare and initialize variables of each primitive type and of String, choosing an appropriate type for given data.
  2. Explain the difference between primitive and reference types at a conceptual level.
  3. Apply Java naming conventions and use final for constants.
  4. Perform widening and narrowing conversions and predict data loss, including integer overflow.
  5. Use var for local variables where the type is obvious.

الدروس

  1. 01المتغيرات كصناديق عليها ملصقات12 د قراءة
  2. 02الأنواع الأولية الثمانية12 د قراءة
  3. 03النصوص (Strings) والأنواع المرجعية12 د قراءة
  4. 04القيم الحرفية والثوابت والتسمية11 د قراءة
  5. 05تحويل الأنواع والتحويل القسري (casting)12 د قراءة
  6. 06استنتاج النوع المحلي باستخدام var12 د قراءة
  7. 07عرض عملي: محوّل وحدات وتجاوز سعة العدد الصحيح12 د قراءة

المختبر والتمارين

Lab

BEG-009-LAB1 · Unit converter (fixed values)

Outcomes: 1–5 · Time: ~2 h Convert hard-coded temperatures, distances, and currencies and print the results with the correct types. Include one deliberate overflow and explain it in a comment. Acceptance: correct output; the overflow is explained.

Exercises (assessment: six exercises plus the type-selection quiz)

IDOutcomeTask
BEG-009-EX011Declare one variable of each type for: age, price in cents, temperature, first initial, is-student, full name.
BEG-009-EX022Explain in two sentences the difference between int and String in how they hold data.
BEG-009-EX033Rename these to Java style: Total_Price, maxspeed, a constant for 3.14159.
BEG-009-EX044Predict, then run: 7 / 2, 7 / 2.0, (int) 9.99, (double) 7 / 2.
BEG-009-EX054Predict the result of Integer.MAX_VALUE + 1, then run it and explain.
BEG-009-EX065Rewrite three declarations with var where the type is obvious; leave one that should not use it.
أظهر الحلول
  • EX01 int age; int priceCents; double temperature; char initial; boolean isStudent; String fullName.
  • EX02 int holds the value directly; String holds a reference to a text object elsewhere.
  • EX03 totalPrice, maxSpeed, final double PI = 3.14159;.
  • EX04 3, 3.5, 9, 3.5.
  • EX05 -2147483648: the value wraps past the maximum of int.
  • EX06 For example var count = 10; and var name = "Ana";; avoid var x = compute();.

الاختبار

Outcomes: O1 declare · O2 primitive vs reference · O3 naming and final · O4 conversion · O5 var.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1Best type for a person's age:O1
  2. 2Best type for true/false:O1
  3. 3Best type for a full name:O1
  4. 4Which type should you NOT use for money in real programs?O1
  5. 5String is a:O2
  6. 6The Java style for a variable name is:O3
  7. 7final on a variable means it:O3
  8. 87 / 2 in Java gives:O4
  9. 9(int) 3.9 gives:O4
  10. 10var x = 10; makes x a(n):O5

الجزء العملي

Six exercises BEG-009-EX01 to EX06 plus the lab. Pass: at least five exercises correct and the overflow explained.

أخطاء شائعة

int division where decimals were expected; using double for money; == on strings (flagged here, explained in BEG-026).

التقييم

6 exercises plus a quiz on type selection.

الصلة بالمسار الوظيفي

Type choice for money returns in JNR-028 (BigDecimal/numeric) and data modeling.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.