Output-Based Java Questions

This Java quiz is a set of classic "what is the output?" questions from interviews and written tests. Each one hides a rule about operators, overloading, initialization order or number types that you need to know cold.

ปานกลาง 10 ข้อ ~6 นาที ผ่านที่ 80% Java 17

เลือกโหมด

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

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

ข้อ 1 จาก 10

What does this print?

public class Main {
    public static void main(String[] args) {
        System.out.println('a' + 1 + "b" + 'a' + 1);
    }
}
ดูเฉลย

B. 98ba1 + is evaluated left to right. 'a' + 1 is char + int, so it is numeric addition: 97 + 1 = 98. Once a String appears, everything after it is concatenated as text.

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

  • char arithmetic and string concatenation order
  • Pre- and post-increment in one expression
  • Overload resolution with null
  • Static blocks, instance blocks and constructors
  • Rounding, overflow, Infinity and NaN

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

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

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

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

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