جافا Java
6.34K subscribers
212 photos
18 videos
81 files
269 links
ليس عيبًا ألا تعرف شيئًا، ولكن العيب انك لا تريد أن تتعلم
Download Telegram
ما ناتج بناء السلسلة داخل لوب؟
What does this string build print?
String s = "a";
for (int i = 0; i < 3; i++) s += i;
System.out.println(s);
🤩1
ما طول الصف الثاني؟
What is the length of the second row?
int[][] m = { {1,2}, {3,4,5} };
System.out.println(m[1].length);
ما مجموع التأثير في 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);
ما قيمة الحقل بعد إنشاء الكائن؟
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);
1
أي عبارة صحيحة عن Overloading/Overriding؟
Which statement is true about overloading/overriding?
ما ناتج التعامل مع 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);
ما أقل معدِّل وصول يسمح لوريث في حزمة مختلفة؟
What is the least permissive modifier that still allows a subclass in a different package to access a member?
سَلسَلة المُنشئات باستخدام this
Constructor chaining with this
class P {
int x;
P(){ this(5); }
P(int x){ this.x = x; }
}
System.out.println(new P().x);
استخدام 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());
تعدد الأشكال (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());
instanceof مع الوراثة
instanceof with inheritance
class A {}
class B extends A {}
A x = new A();
System.out.println(x instanceof B);