C#: oop va sinflar Test 1 1-mashq


Download 1.49 Mb.
bet56/101
Sana31.01.2024
Hajmi1.49 Mb.
#1828853
1   ...   52   53   54   55   56   57   58   59   ...   101
Bog'liq
ATD (1)

Javob:

(1) Out(a,2) + Out(b,3)


(2) Tashqarida(a,3) + Out(b,2)


(3) Out(a.F,3) + Out(b.F,2)


(4) Out(a.F(3)) + Out(b.F(2))


(5) Out(a.F(2)) + Out(b.F(3))


5 raqami
Manba modulida quyidagi kod mavjud:
interfeysi IForm { int F(int x); }
sinf A: IPrrmула{ public int F(int x) { return x*x*x; } }
B klassi: I FRrmуlа{ public int F(int x) { return x*x; } }
sinf dasturi
{
statik int Out(IФорmула f, int x ) {qaytarish f.F(x); }
statik bo'shliq Asosiy ()
{
A a = yangi A(); B b = yangi B();
System.Console.WriteLine( _________________);
}
}
Quyida keltirilgan kodlar orasida underscores o'rniga pastki o'rniga 2*2*2 + 4*4 hisoblash uchun to'g'ri dasturni olish imkonini beruvchi kodni belgilang:

Javob:
(1) Out(a, 2) + Out(b, 4)


(2) Tashqarida(a,4)+ tashqarida(b,2)


(3) Tashqarida(a.F,2)+ tashqarida(b.F,4)


(4) Out(a.F(2)+Out(b.F(4))


(5) Tashqarida(a.F (4)+ tashqarida(b.F(2))


6-masala
Manba modulida quyidagi kod mavjud:
interfeysi IForm { int F(int x); }
sinf A: IPrrmула{ public int F(int x) { return x*x*x; } }
B klassi: I FRrmуlа{ public int F(int x) { return x*x; } }
sinf dasturi
{
statik int Out(IФорmула f, int x ) {qaytarish f.F(x); }
statik bo'shliq Asosiy ()
{
A a = yangi A(); B b = yangi B();
System.Console.WriteLine(Out(a, 3) + Out(b, 4));
}
}
Quyida sanab o'tilgan kodlar orasida underscores o'rniga pastki o'rnini bosuvchi kodni ko'rsating, 3*3*3 + 2*2 ni hisoblash uchun to'g'ri dasturni olish imkonini beradi:

Javob:
(1) Out(a, 2) + Out(b, 2)



Download 1.49 Mb.

Do'stlaringiz bilan baham:
1   ...   52   53   54   55   56   57   58   59   ...   101




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling