438
مشترکین
-224 ساعت
-27 روز
-1330 روز
آرشیو پست ها
is another one of the core concepts of object oriented programing it focuses on establishing a strong has a relationship between the three class
has a relationship denotes a whole part relatiosnship where a part cannot exist whithout the whole
Naming a unchecked exception by checked because it checks at
superclass is typically a more specialized version of its subclass
the transitive natire of inheriance is reflected by this from of inheriance
type of inheriance
1.single inheriance
2.multilevel inheriance
3.Hierarchical inheriance
4.hybrid inheriance
الخامسة متدعمش فيها الجافا
5. multiple inheriance
:
interface InterfaceA {
default void display() {
System.out.print("#");
}
}
interface InterfaceB {
void display(); // دالة مجردة
}
class ImplementationClass implements InterfaceA, InterfaceB {
@Override
public void display() {
System.out.println("Display method in ImplementationClass");
}
}
public class Main {
public static void main(String[] args) {
ImplementationClass obj = new ImplementationClass();
obj.display(); ImplementationClass
}
}:
class Shape {
protected int x;
public Shape(int x) {
this.x = x;
System.out.println("Shape constructor called with x = " + this.x);
}
}
class Circle extends Shape {
private int radius;
public Circle(int x, int radius) {
this.radius = radius;
System.out.println("Circle constructor called with radius = " + this.radius);
}
}
public class Main {
public static void main(String[] args) {
Circle circle = new Circle(10, 5);
}
}class Shape {
protected int x; // متغير x
// منشئ يأخذ قيمة String
public Shape(String x) {
this.x = Integer.parseInt(x);
System.out.println("Shape constructor called with x = " + this.x);
}
// منشئ فارغ لتعيين قيمة افتراضية لـ x
public Shape() {
this.x = 0; // تعيين قيمة افتراضية لـ x
System.out.println("Default Shape constructor called with x = " + this.x);
}
}
class Circle extends Shape {
private int radius;
// منشئ يأخذ radius فقط ويقوم بتهيئة x مباشرة باستخدام الكونستركتر الافتراضي
public Circle(int radius) {
this.radius = radius;
this.x = 0; // تعيين قيمة مباشرة لـ x إذا كنت لا تريد استخدام super
System.out.println("Circle constructor called with radius = " + this.radius);
}
public void show() {
System.out.println("Radius: " + radius);
System.out.println("Shape's x: " + this.x); // الوصول إلى متغير x من الفئة الأساسية
}
}
public class Program4 {
public static void main(String[] args) {
Circle c1 = new Circle(10);
c1.show();
}}جمعة طيبة للجميع
الرجاء ابلاغ جميع الطلبة بان
Array list and array of object
غير داخلة للامتحان
Repost from N/a
الجماعة اللي ياخدو من منهج ال oop ال pdf بتاع سارية
راهو في نسخة قديمة(اسمها OOP منهج كامل) ناقصة صفحات عن ال has a ومنعرفش لو في نقص اخرى
ف هدي النسخة الجديدة
