❓ هل a == b صحيح؟
Is a == b true?
Is a == b true?
String a = new String("hi");
String b = "hi";
System.out.println(a == b);❓ Switch على String بدون break بعد "two"؟
Switch on String (no break after "two")?
Switch on String (no break after "two")?
String s = "two";
switch (s) {
case "one": System.out.print(1); break;
case "two": System.out.print(2);
default: System.out.print(0);
}
❤1
❓ تمرير المصفوفات للميثود: ماذا يُطبع؟
Passing arrays to methods: what prints?
Passing arrays to methods: what prints?
void change(int[] arr) {
arr[0] = 99;
arr = new int[]{7,7,7};
}
int[] x = {1,2,3};
change(x);
System.out.println(x[0]);2👍1
❓ تأثير i++ داخل شرط while؟
Effect of i++ in while condition?
Effect of i++ in while condition?
int i = 0;
while (i++ < 3) { }
System.out.println(i);
❓ كم عدد الزيادات؟
How many increments occur?
How many increments occur?
int c = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j <= i; j++) {
c++;
}
}
System.out.println(c);
❤1
❓ كيف يعمل fall-through عندما يطابق case 1؟
How does fall-through work here?
How does fall-through work here?
int d = 1;
switch (d) {
case 0: d += 2;
default: d += 3;
case 1: d += 4;
}
System.out.println(d);
👍2
❓ أي استدعاء يُفضَّل مع varargs؟
Which overload is chosen with varargs?
Which overload is chosen with varargs?
static void m(int x) { System.out.print("exact"); }
static void m(int... x) { System.out.print("varargs"); }
m(5);👍2
❓ ما نتيجة البحث بعد الفرز؟
What is binarySearch result after sort?
What is binarySearch result after sort?
int[] a = {3, 1, 2};
java.util.Arrays.sort(a);
System.out.println(java.util.Arrays.binarySearch(a, 2));❓ ما ناتج حساب المضروب البسيط؟
What does this factorial-like loop print?
What does this factorial-like loop print?
int n = 3, r = 1;
for (int i = 1; i <= n; i++) r *= i;
System.out.println(r);
❓ تأثير العامل الثلاثي مع الزيادات؟
Ternary with increments effect?
Ternary with increments effect?
int a = 1, b = 2;
int x = (a++ > 1) ? a : b++;
System.out.println(a + "," + b + "," + x);
👍1
❓ ما ناتج بناء السلسلة داخل لوب؟
What does this string build print?
What does this string build print?
String s = "a";
for (int i = 0; i < 3; i++) s += i;
System.out.println(s);
👍2