Skip to content

Commit 0f7946d

Browse files
authored
Create solution.txt file
1 parent 4cfd200 commit 0f7946d

File tree

1 file changed

+247
-0
lines changed

1 file changed

+247
-0
lines changed

Solution.txt

+247
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
ex1 -> Class b - בגלל מנגנון ה - polymorphism
2+
ex2 -> public void method1(float y)
3+
ex3 -> אם הרשאת הגישה לשיטה f שבמחלקה A היא protected והרשאת הגישה לשיטה f שבמחלקה B היא private.
4+
ex4 ->המחלקות Computer ו-TV יורשות מהמחלקה ElectronicDevice והמחלקה Laptop יורשת מהמחלקה
5+
ex5 -> הפלט יהיה: B
6+
ex6 -> המחלקה A מכילה שיטה בשם f שאינה מקבלת פרמטרים.
7+
ex7 -> שגיאת קומפליציה
8+
ex8 -> שגיאת זמן ריצה
9+
ex12 -> על הפלט יודפס dd
10+
ex13 -> שגיאת קומפליציה
11+
ex14 -> על הפלט יודפס 3 ובשורה שאחריה יודפס 10
12+
ex15 -> שגיאת קומפליציה
13+
ex16 -> על הפלט יודפס 1
14+
ex17 -> Card
15+
ex18 -> כל קטע קוד הנכתב באחת מן המחלקות היורשות זמין באופן מיידי במחלקה - האם ובכל אחיותיה בעת הירושה
16+
ex19 -> המחלקות poodle , dalmation יורשות מהמחלקה dog והמחלקות dog and cat יורשות מהמחלקה mammal
17+
ex20 -> כל התשובות האחרות אינן נכונות
18+
19+
public class ClassA
20+
{
21+
public ClassA()
22+
{
23+
f();
24+
}// end of method ClassA
25+
26+
public void f()
27+
{
28+
System.out.println("Class a");
29+
}// end of method f
30+
31+
public static void main(String[] args)
32+
{
33+
new ClassB();
34+
}// end of method main
35+
}// end of class ClassA
36+
37+
38+
public class ClassB extends ClassA
39+
40+
{
41+
42+
public ClassB() {}
43+
44+
45+
46+
public void f()
47+
48+
{
49+
50+
System.out.println("Class b");
51+
52+
}
53+
54+
}
55+
56+
public class A {
57+
58+
public void method1(float x){ … }
59+
60+
}
61+
62+
public class A
63+
{
64+
public void a1()
65+
{
66+
System.out.println("A");
67+
}// end of method a1
68+
69+
public void a2()
70+
{
71+
a1();
72+
}// end of method a2
73+
}// end of class A
74+
75+
76+
77+
public class B extends A
78+
{
79+
@Override
80+
public void a1()
81+
{
82+
System.out.println("B");
83+
}// end of method a1
84+
}// end of class B
85+
86+
87+
public class C
88+
{
89+
public void foo(D d)
90+
{
91+
System.out.println("cd");
92+
}
93+
}// end of class C
94+
95+
96+
97+
98+
public class D extends C
99+
{
100+
public void foo(C c)
101+
{
102+
System.out.println("dc");
103+
}// end of methdo foo
104+
105+
public void foo(D d)
106+
{
107+
System.out.println("dd");
108+
}
109+
110+
}// end of method class D
111+
112+
113+
public class A
114+
{
115+
public void doSomething(int x)
116+
{
117+
System.out.println("1");
118+
}// end of method doSomething
119+
120+
public void doSomethingElse(int x, int y)
121+
{
122+
System.out.println("2");
123+
}// end of method doSomethingElse
124+
125+
public int calc (int x)
126+
{
127+
System.out.println("3");
128+
return x + 1;
129+
}// end of method calc
130+
131+
}// end of class A
132+
133+
134+
public class B extends A
135+
{
136+
public void doSomethingElse(int x)
137+
{
138+
System.out.println("4");
139+
}// end of method doSomethingElse
140+
}// end of class B
141+
142+
143+
public class D extends A
144+
{
145+
public void calc(int x, int y)
146+
{
147+
System.out.println(7+y+x);
148+
}// end of method calc
149+
}// end of class D
150+
151+
152+
public class C extends A
153+
{
154+
public void doSomething(int x)
155+
{
156+
System.out.println("5");
157+
}// end of method doSomething
158+
}// end of class C
159+
160+
161+
public class E extends C
162+
{
163+
public int calc(int x)
164+
{
165+
System.out.println("8");
166+
return x + 3;
167+
}// end of method calc
168+
}// end of class E
169+
170+
public abstract class A
171+
{
172+
public abstract boolean f(int x);
173+
}// end of abstract class A
174+
175+
176+
public abstract class B extends A
177+
{
178+
public boolean f(int x)
179+
{
180+
return x == 2;
181+
}
182+
}// end of abstract class B
183+
184+
public class A
185+
{
186+
private int _x;
187+
public A(int x)
188+
{
189+
_x = x;
190+
}// end of method A
191+
192+
public int getX()
193+
{
194+
return _x;
195+
}// end of method getX
196+
197+
public int doubleX()
198+
{
199+
return 2 * getX();
200+
}// end of method doubleX
201+
202+
public int tripleX()
203+
{
204+
return 3 * _x;
205+
}// end of method tripleX
206+
207+
public int subXhelper()
208+
{
209+
return _x -1;
210+
}// end of method subXhelper
211+
212+
public int subX()
213+
{
214+
return subXhelper();
215+
}// end of method subX
216+
}// end of class A
217+
218+
public class B extends A
219+
{
220+
private int _x;
221+
222+
public B(int xA, int xB)
223+
{
224+
super(xA);
225+
_x = xB;
226+
}// end of method B
227+
228+
public int getX()
229+
{
230+
return _x;
231+
}// end of method getX
232+
233+
public int superX()
234+
{
235+
return super.getX();
236+
}// end of method superX
237+
238+
public int tenTimesX()
239+
{
240+
return 10 * _x;
241+
}// end of method tenTimesX
242+
243+
public int subXhelper()
244+
{
245+
return _x * 2;
246+
}// end of method subXhelper
247+
}// end of class B

0 commit comments

Comments
 (0)