C#: oop va sinflar Test 1 1-mashq


Download 1.49 Mb.
bet69/101
Sana31.01.2024
Hajmi1.49 Mb.
#1828853
1   ...   65   66   67   68   69   70   71   72   ...   101
Bog'liq
ATD (1)

Javob:
1) Ivanovda «Mersedes» bor


2) Petrovning Mercedes bor


3) Petrovda Ford bor


(4) dastur qulab tushadi


(5) Bir yoki bir qancha sintaksis xatoliklari aniqlanganligi sababli dastur bajarib bo'lmadi


4 raqami
Manba modulida quyidagi atamalar mavjud:
struct Light ampul {
ommaviy int kuchi;
public Bulb(int kuchi){this.power=power;} }
sinf Appliance {
umumxalq nur lampochkasi[] llamalari;
ommaviy asbob-uskunalar(Llama lampasi)
{ this.lam = new Light Lam[2]; bu.lam[0]=this.lam[1]=lam;}
ommaviy int Quvvat
{ olish {
int s=0;
uchun (int i = 0; i < lam. Uzunligi; i++) s += lam[i].kuch;
qaytarish s; }
} }
Program sinfida Asosiy metod aniqlanadi, uning tanasida kod mavjud:
Llama Lampa = yangi chiroq(50);
Applikance pr1=new Appliance(lam);
lam.kuch = 100;
Applikance pr2=new Appliance(lam);
System.Console.WriteLine(w1.Power + w2.Power);
Main () usuli bajarilgandan so'ng konsolga chiqishni ko'rsating:

Javob:
1) 300


2) 200


3) 400


4) 100


5) 150


5 raqami
Manba modulida quyidagi atamalar mavjud:
struct Light ampul {
ommaviy int kuchi;
public Bulb(int kuchi){this.power=power;} }
sinf Appliance {
umumxalq nur lampochkasi[] llamalari;
ommaviy asbob-uskunalar(Llama lampasi)
{ this.lam = new Light Lam[2]; bu.lam[0]=this.lam[1]=lam;}
ommaviy int Quvvat
{ olish {
int s=0;
uchun (int i = 0; i < lam. Uzunligi; i++) s += lam[i].kuch;
qaytarish s; }
} }
Program sinfida Asosiy metod aniqlanadi, uning tanasida kod mavjud:
Llama Lampa = yangi chiroq(50);
Applikance pr1=new Appliance(lam);
Applikance pr2=new Appliance(lam);
lam.kuch = 100;
System.Console.WriteLine(w1.Power + w2.Power);
Main () usuli bajarilgandan so'ng konsolga chiqishni ko'rsating:


Download 1.49 Mb.

Do'stlaringiz bilan baham:
1   ...   65   66   67   68   69   70   71   72   ...   101




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