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

أول برنامج بلغة Java

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

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

نظرة عامة

الموضوعات

  • صياغة Java
  • main()
  • الفئات (classes)
  • العبارات (statements)
  • التعليقات
  • الإخراج على الطرفية

تعلّم أولًا

70 دقيقة قراءة · 2 ساعة تدريب (تقدير)

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

  1. Identify the parts of a minimal Java program: class declaration, main method signature, statements, braces.
  2. Print text and simple values with System.out.println and System.out.print.
  3. Write single-line, multi-line, and Javadoc comments, and explain when a comment is useful.
  4. Fix the five most common beginner syntax errors from the compiler message alone.

الدروس

  1. 01تشريح Hello World12 د قراءة
  2. 02العبارات والفاصلة المنقوطة والكتل11 د قراءة
  3. 03طباعة المخرجات11 د قراءة
  4. 04التعليقات12 د قراءة
  5. 05قراءة أخطاء المترجم12 د قراءة
  6. 06عرض عملي: إصلاح خمسة برامج معطّلة من رسائل المترجم12 د قراءة

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

Lab

BEG-008-LAB1 · Business card

Outcomes: 1–4 · Time: ~2 h

  1. Print a formatted multi-line business card (name, role, email, phone) using println and print.
  2. Add a Javadoc comment on the class and one useful // comment.
  3. Fix the five broken programs below using only the compiler messages.

Acceptance: all five compile and print Hello; the card prints as designed.

The five broken programs (all should print Hello)
java
// B1
public class B1 {
    public static void main(String[] args) {
        System.out.println("Hello")
    }
}
java
// B2
public class B2 {
    public static void main(String[] args) {
        system.out.println("Hello");
    }
}
java
// B3
public class B3 {
    public static void main(String[] args) {
        System.out.println("Hello");
    }
java
// B4
public class B4 {
    public static void main(String args) {
        System.out.println("Hello");
    }
}
java
// B5
public class B5 {
    public static void main(String[] args) {
        System.out.println("Hello);
    }
}

Exercises (assessment: EX01–EX05)

IDOutcomeTask
BEG-008-EX011Label the parts of Hello World: class line, main line, braces, statement.
BEG-008-EX022Print your name on one line and your city on the next, using only print.
BEG-008-EX032Print Total: 3 items by joining text and the number 3.
BEG-008-EX043Add a single-line, a multi-line, and a Javadoc comment to any program. Which one would you keep and why?
BEG-008-EX054Rename main to Main and read the error. What does the JVM say?
أظهر الحلول
  • Lab fixes B1 add ;. B2 System. B3 add the final }. B4 String[] args. B5 close the quote.
  • EX01 public class Hello is the class line; public static void main(String[] args) is the entry point; { } are blocks; System.out.println(...); is the statement.
  • EX02 System.out.print("Ana\n"); System.out.print("Cairo");
  • EX03 System.out.println("Total: " + 3 + " items");
  • EX04 Keep comments that explain why, not what.
  • EX05 Compile succeeds but running reports that no main method was found.

الاختبار

Outcomes: O1 program parts · O2 printing · O3 comments · O4 compiler errors.

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

  1. 1Where does a Java program start?O1
  2. 2The correct main line is:O1
  3. 3Hello.java must contain:O1
  4. 4Java is:O1
  5. 5System.out.println("A"); System.out.println("B"); prints:O2
  6. 6"Age: " + 30 produces:O2
  7. 7Which is a Javadoc comment?O3
  8. 8A good comment explains:O3
  9. 9';' expected usually means:O4
  10. 10For system.out.println("Hi"); the compiler reports package system does not exist. The most likely cause is:O4

الجزء العملي

Assessment is BEG-008-EX01 to EX05 plus the five broken programs. Pass: at least four of five programs fixed.

أخطاء شائعة

Case sensitivity (system.out), missing semicolons, mismatched braces, misspelling main's signature.

التقييم

5 exercises (BEG-008-EX01..05).

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

Reading compiler and tool output is a daily skill at every level.

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