Dasturlash tillari va axborot-kommunikatsiya texnologiyalari 1-semestr
311
class Test {
public int x;
public static int mymeth1(Test ob){
return ob.x/5;}
public static void mymeth2(){
x=30; Console.Write(mymeth1(x));}}
A) 5
B) 4
C) 6
D) 3
E) 2
14. Dasturni ishga tushirganda ekranda qanday natija xosil bo‘ladi?
using System;
class Test {
int x,y;
public Test(){x=y=0;}
public Test(int i, int j ){x=i; y=j;}
public static Test operator +(Test ob1, Test ob2){
Test nat=new Test();
nat.x=-(ob1.x+ob2.y);
nat.y=-(ob1.y+ob2.x);
return nat;}
public void kur(){
Console.WriteLine(x+ ", " +y);}}
class Tek{
public static void Main() {
Test a=new Test(-2, 4);
Test b=new Test(5, -1);
Test c=new Test();
c=a+b;
c.kur();}}
A) 3, -9
B) -3, -3
C) 3, 3
D) -2, -4
E) xatolik beradi
Do'stlaringiz bilan baham: