C#: oop va sinflar Test 1 1-mashq


Download 1.49 Mb.
bet101/101
Sana31.01.2024
Hajmi1.49 Mb.
#1828853
1   ...   93   94   95   96   97   98   99   100   101
Bog'liq
ATD (1)

Javob:
1) Dastur tugallangan. s=21


2) s=21


3) Istisno-1. s=21


4) Istisno-1. Dastur tugallangan. s=21


5) Istisno-1. Dastur tugallangan.


6-masala
System namespace uchun quyidagi kod mavjud.
Class MyExc : ApplicationException
{ public MyException1() : base("Exception-1") { }
public override string ToString() { return "Иссклеклекие-3"; }
ommaviy statik int usuli()
{ int s = 22;
sinab ko'ring { s = s / (s - 22); }
catch (DivideByZeroException)
{ Console.Write("Istisno-2. "); yangi MyExc tashlang (); }
qaytarish s;
} }
sinf imtihoni
{ ommaviy statik bo'shliq Main()
{ int s=0;
sinab ko'ring { s = MyExc.Method(); }
catch (MyExc ex) { Console.Write(ex); }
Konsol.WriteLine(" s=" + s);
} }
Kompilyatsiya qilish va ishga tushirish uchun dasturni ishga tushirishga uringandan so'ng konsolga chiqish natijasini ko'rsating:

Javob:
(1) Istisno-2 DivideByZeroException


2) Istisno-2 Istisno-1 s=0


3) Istisno-2 MyExc s=0


(4) MyExc Istisno-2


5) Istisno-2 Istisno-3 s=0
Download 1.49 Mb.

Do'stlaringiz bilan baham:
1   ...   93   94   95   96   97   98   99   100   101




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