ควิซ Java: if, switch & Loops

This Java control flow quiz checks how if, switch, for, while and do-while really run. You will trace loops with break and continue, catch switch fall-through and spot loops that never end or run past an array.

ง่าย 10 ข้อ ~5 นาที ผ่านที่ 80% Java 17

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

ตัวอย่างคำถาม

ข้อ 1 จาก 10

What does this print?

public class Main {
    public static void main(String[] args) {
        int day = 2;
        switch (day) {
            case 1: System.out.print("A");
            case 2: System.out.print("B");
            case 3: System.out.print("C");
                break;
            default: System.out.print("D");
        }
        System.out.println();
    }
}
ดูเฉลย

C. BC The switch jumps to case 2 and then falls through into case 3 because there is no break after B. The break after C stops it before default.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • Classic switch fall-through and break
  • Switch expressions with ->
  • for, enhanced for, while and do-while
  • break and continue
  • Common bugs like off-by-one and infinite loops

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง