جافا Java
前往频道在 Telegram
6 096
订阅者
-224 小时
-87 天
-3630 天
帖子存档
6 096
❓ instanceof مع الوراثة
instanceof with inheritance
class A {}
class B extends A {}
A x = new A();
System.out.println(x instanceof B);6 096
❓ تعدد الأشكال (Polymorphism)
Polymorphism dispatch
class A { String f(){ return "A"; } }
class B extends A { String f(){ return "B"; } }
A x = new B();
System.out.println(x.f());6 096
❓ استخدام super في override
Using super in an override
class A { String f(){ return "A"; } }
class B extends A { String f(){ return super.f() + "B"; } }
System.out.println(new B().f());6 096
❓ سَلسَلة المُنشئات باستخدام this
Constructor chaining with this
class P {
int x;
P(){ this(5); }
P(int x){ this.x = x; }
}
System.out.println(new P().x);6 096
❓ ما أقل معدِّل وصول يسمح لوريث في حزمة مختلفة؟
What is the least permissive modifier that still allows a subclass in a different package to access a member?
6 096
❓ ما ناتج التعامل مع static مقابل instance؟
What prints for static vs instance fields?
class C { static int s=0; int i=0; C(){ s++; i++; } }
C a = new C();
C b = new C();
System.out.println(C.s + "," + b.i);6 096
❓ أي عبارة صحيحة عن Overloading/Overriding؟
Which statement is true about overloading/overriding?
6 096
❓ ما قيمة الحقل بعد إنشاء الكائن؟
What is the field value after object creation?
class A { int v = 1; A(){ v *= 2; } }
A a = new A();
System.out.println(a.v);6 096
❓ ما مجموع التأثير في switch مع default؟
Total effect in switch with default?
int x = 0;
int v = 3;
switch (v) {
case 1: x += 1; break;
case 2:
case 3: x += 3;
default: x += 5; break;
}
System.out.println(x);6 096
❓ ما طول الصف الثاني؟
What is the length of the second row?
int[][] m = { {1,2}, {3,4,5} };
System.out.println(m[1].length);