עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

שאלה בירושה ופולימורפים

Featured Replies

פורסם

נתונות המחלקות הבאות:

public abstract class A{
protected int _x;
public abstract void d(int y);
public String toString() {
return ""+_x;
}
}

public abstract class B extends A
{
private int _y;


public B()
{
super();
_y = 1;
}

public String toString()
{
return ""+_x + "."+_y;
}
}
public class C extends B
{
private int _z;


public C()
{
super();
_z = 10;
}


public void d(int y)
{
_x += (y+_z);
}


public String toString()
{
return
super.toString()+"."+_z;
}


}

main:

	public static void main(String[] args)	{
A a = new C();
B b = new C();
C c = new C();
System.out.println ("a: " + a + "\nb: " + b + "\nc: " + c);
}

מה שאני לא מבין זה למה הפלט הוא

a: 0.1.10b: 0.1.10

c: 0.1.10

הרי כשיש new C אני נכנס ל-C פוגש בסופר ואז הולך ל-B ופוגש את הסופר שוב ול-A אין בנאי ריק בכלל

פורסם

לכל מחלקה שלא הגדרת לה בנאי יש אוטומטית בנאי ריק (שלא עושה כלום).

פורסם
  • מחבר

אבל למה הערכים של A,B ו-C הם כאלו ? (אשמח להסבר)

פורסם

מה יש להסביר? פשוט תעקוב אחרי מה שהבנאים עושים.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.