❓ ترتيب كتل static مع الوراثة
Static init order with inheritance
Static init order with inheritance
class A { static { System.out.print("A"); } }
class B extends A { static { System.out.print("B"); } }
new B();❓ خطأ فهرسة في حلقة
Index error in loop
Index error in loop
int[] a = {1,2,3};
for (int i = 0; i <= a.length; i++) {
System.out.print(a[i]);
}❓ ما ناتج الكود التالي؟
What is the output of the following code?
What is the output of the following code?
int x = 5;
if (x > 3) x++;
if (x == 6) x += 2;
System.out.println(x);
❓ ما مجموع الأعداد من 1 إلى 3؟
What does this loop print?
What does this loop print?
int sum = 0;
for (int i = 1; i <= 3; i++) {
sum += i;
}
System.out.println(sum);
❓ ما ناتج السويتش بدون break؟
What is the output (no breaks before case 3)?
What is the output (no breaks before case 3)?
int n = 2;
switch (n) {
case 1: System.out.print('A');
case 2: System.out.print('B');
case 3: System.out.print('C'); break;
default: System.out.print('D');
}
❓ أي overload يُستدعى؟
Which overload is invoked?
Which overload is invoked?
void print(int x) { System.out.println("int"); }
void print(Integer x) { System.out.println("Integer"); }
Integer n = null;
print(n);❓ كيف تطبع طول المصفوفة؟
How do you print the array length?
How do you print the array length?
int[] a = {1, 2, 3, 4};
System.out.println( /* ? */ );❓ هل يعدّل for-each عناصر المصفوفة؟
Does for-each modify elements?
Does for-each modify elements?
int[] a = {1, 2, 3};
for (int x : a) { x *= 2; }
System.out.println(a[1]);❓ ما قيمة count بعد استخدام continue؟
What is count after using continue?
What is count after using continue?
int count = 0;
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) continue;
count += i;
}
System.out.println(count);
1❤1
❓ هل a == b صحيح؟
Is a == b true?
Is a == b true?
String a = new String("hi");
String b = "hi";
System.out.println(a == b);