❓ استخدام super في override
Using super in an 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
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
instanceof with inheritance
class A {}
class B extends A {}
A x = new A();
System.out.println(x instanceof B);❓ equals مقابل == مع السلاسل
equals vs == with Strings
equals vs == with Strings
String s1 = new String("java");
String s2 = new String("java");
System.out.println(s1.equals(s2) + "," + (s1 == s2));❓ أي عبارة صحيحة عن String و StringBuilder؟
Which is true about String vs StringBuilder?
Which is true about String vs StringBuilder?
What does this ArrayList code print?
import java.util.*;
List<Integer> xs = new ArrayList<>();
xs.add(1);
xs.add(2);
System.out.println(xs.get(0) + xs.get(1));
❓ الوراثة مع مُنشئ أب مُعَلَّم
Inheritance with parameterized base constructor
Inheritance with parameterized base constructor
class Base { Base(int x) {} }
class Child extends Base { }
جافا Java
❓ الوراثة مع مُنشئ أب مُعَلَّم Inheritance with parameterized base constructorclass Base { Base(int x) {} } class Child extends Base { }
Choose your answer:
Anonymous Quiz
40%
Compiles successfully
36%
Does not compile: Child must call super(int)
25%
Does not compile: Base needs a no-arg constructor
👍3
❓ التعامل مع الاستثناءات في finally
Try-catch-finally order
Try-catch-finally order
try {
int x = 1 / 0;
System.out.print("A");
} catch (ArithmeticException e) {
System.out.print("B");
} finally {
System.out.print("C");
}