تجمع شيتات واسئلة oop
الذهاب إلى القناة على Telegram
438
المشتركون
-224 ساعات
-27 أيام
-1330 أيام
أرشيف المشاركات
Repost from قناة منهج كلية تقنية المعلومات |2005|
Composition is a feature of java, not a design technique but we can achieve it using Java code.
Repost from قناة منهج كلية تقنية المعلومات |2005|
في interface، لما بنعرفوا متغير، ضروري نعطوه قيمة و إلا حيعتبر compile time error، و السبب علشان أنه static.
class A {
private int x = 0;
A() {
x++;
System.out.println(x);
}
A(int x, int y) {
System.out.println(x + y);
}
}
class B extends A {
private int x = 17;
B() {
super();
System.out.println("(" + 2 + ", " + 2 + ")");
}
B(int x, int y) {
super(x, y);
}
}
public class programs5 {
public static void main(String[] args) {
B obj = new B();
}
}class Shape {
Shape(int size) {
System.out.println("Shape constructor called with size = " + size);
}
}
// تعريف الفئة Circle التي تمتد من Shape
class Circle extends Shape {
Circle(int radius) {
super(10); // استدعاء كونستركتور Shape مع قيمة 10
System.out.println("Circle constructor called with radius = " + radius);
}
}
// الفئة الرئيسية لاختبار الكود
public class Main {
public static void main(String[] args) {
Circle circle = new Circle(5); // إنشاء كائن من نوع Circle
}
}ترجمة الاساتذة متحطش املكم فيها واجد صح يساعدو ويسهلو لاكن مش لدرجة تقرا بلعربي ومتبحتش الانجليزي بكل مش غباء هوا مرات الاساتذة ميمروش على كل القاعات بحكم ان المجموعات موزعات عشوائي مش كل مجموعة بروحها.... فلاستاذ يسهل بس ويوضح حاجة مش مفهومة مش لدرجة يترجم قوقل بشوية نين انت تحل....
هيمر مرور الكرام وبارك الله فيه بزيادة لو مر اصلا
