Ichma ich joylashgan if shartli operatori, switch tanlash operatori


OB'EKTGA YO’NALTIRILGAN FIKRLASH. STRING SINFI OBYEKTLAR MASSIVI. STRING SINFI



Download 138,54 Kb.
bet5/10
Sana31.01.2022
Hajmi138,54 Kb.
#419912
1   2   3   4   5   6   7   8   9   10
Bog'liq
Testlar Dasturlash1-semestr savollar

OB'EKTGA YO’NALTIRILGAN FIKRLASH. STRING SINFI OBYEKTLAR MASSIVI. STRING SINFI

111. Quyidagi dastur qanday natijani chop etadi?


string s("abc");
s.append("welcome");
cout << s << endl;

112. Quyidagi dastur qanday natijani chop etadi?
string s("abc");
s.append("welcome", 0, 3);
cout << s << endl;

113. Quyidagi dastur qanday natijani chop etadi?
string s("abc");
s.append("welcome", 3);
cout << s << endl;

114. Quyidagi dastur qanday natijani chop etadi?
string s("abc");
s.append(3, 'w');
cout << s << endl;

116. Quyidagi dastur qanday natijani chop etadi?
string s("abc");
s.assign("welcome", 3);
cout << s << endl;

117. Quyidagi dastur qanday natijani chop etadi?
string s("abc");
s.assign(3, 'w');
cout << s << endl;

118. Quyidagi dastur qanday natijani chop etadi?
string s("abcd");
cout << s.at(1) << endl;

119. Quyidagi dastur qanday natijani chop etadi?
string s("abcd");
cout << s.length() << endl;

120. Quyidagi dastur qanday natijani chop etadi?
string s("abcd");
cout << s.size() << endl;

121. Quyidagi dastur qanday natijani chop etadi?
string s("abcd");
s.clear();
cout << s.length() << endl;

122. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
cout << s.compare("abb") << endl;

123. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
s.erase(2, 3);
cout << s << endl;

124. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
char s1[15] = "welcome";
s.copy(s1, 3, 0);
cout << s1 << endl;

125. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
cout << s.substr(1, 3);

126. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
cout << s.substr(3);

127. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
string s1("welcome");
s.swap(s1);
cout << s << endl;

128. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefag");
cout << s.find("def") << " " << s.find("a", 3);

129. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
s.replace(1, 2, "wel");
cout << s << endl;

130. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
s.insert(1, "wel");
cout << s << endl;

131. Quyidagi dastur qanday natijani chop etadi?
string s("abcdefg");
s.insert(1, 3, 'w');
cout << s << endl;

132. Quyidagi keltirilgan izohlardan qaysi biri to’g’ri?

  1. C++ dasturlash tili bizga obyekt turidagi argumentni funksiyaga qiymat orqali yuborishga ruxsat beradi.

  2. C++ dasturlash tili bizga obyekt turidagi argumentni funksiyaga havola orqali yuborishga ruxsat beradi.

  3. Argumentni havola orqali yuborish hotirani tejaydi.

  4. Funksiyaga o`zarmas parametrli havola yuborganingizda ,funksiya qiymati o’zgarmaydi.

133. Parametr sifatida obyektni havola orqali murojaat qilganda_____ amalga oshadi.
10.24.Quyidagi dastur kodi qanday natijani chop etadi?
#include
using namespace std;
class Count
{ public:
int count;
Count(int c)
{count = c;
} Count()
{ count = 0;
}
};void increment(Count c, int times)
{
c.count++;
times++;
} int main()
{ Count myCount;
int times = 0;
for (int i = 0; i < 100; i++)
increment(myCount, times);
cout << "myCount.count is " << myCount.count;
cout << " times is " << times;
return 0;
}

134. Quyidagi dastur kodi qanday natijani chop etadi?
#include
using namespace std;
class Count
{
public:
int count;
Count(int c)
{ count = c;
} Count()
{
count = 0;
}
}; void increment(Count &c, int &n)
{ c.count++;
n++;
} int main()
{ Count myCount;
int times = 0;
for (int i = 0; i < 100; i++)
increment(myCount, times);
cout << "myCount.count is " << myCount.count;
cout << " times is " << times;
return 0;
}
135. Quyidagi dastur kodi qanday natijani chop etadi?
#include
using namespace std;
class Count
{ public:
int count;
Count(int c)
{ count = c;
} Count()
{ count = 0;
}};
void increment(Count c, int &n)
{ c.count++;
n++;
} int main()
{ Count myCount;
int times = 0;
for (int i = 0; i < 100; i++)
increment(myCount, times);
cout << "myCount.count is " << myCount.count;
cout << " times is " << times;
return 0;
}
136. Quyidagi dastur kodini tahlil qiling:
#include
using namespace std;
class A
{ public:
A();
double getNumber();
private:
double number;
}; A::A()
{ number = 1;
} double A::getNumber()
{return number;
} void printA(const A &a)
{ cout << "The numberr is " << a.getNumber() << endl;
}int main ()
{ A myObject;
printA(myObject);

return 0;


}
137. Quyidagi dastur kodini tahlil qiling:
#include
#include
using namespace std;
class Name
{
public:
string firstName;
char mi;
string lastName;
Name(string firstName1, char mi1, string lastName1)
{
firstName = firstName1;
mi = mi1;
lastName = lastName1;
}
};
int main()
{
string firstName("John");
Name name(firstName, 'F', "Smith");
firstName = "Peter";
name.lastName = "Pan";
cout << name.firstName << " " << name.lastName << endl;
}

138. Quyidagi dastur kodini tahlil qiling:
#include
#include
using namespace std;
class Name
{ public:
string firstName;
char mi;
string lastName;
Name(string firstName1, char mi1, string lastName1)
{ firstName = firstName1;
mi = mi1;
lastName = lastName1; } };
int main()
{ string firstName("John");
Name name(firstName, 'F', "Smith");
firstName = "Peter";
name.lastName = "Pan";
cout << name.firstName << " " << name.lastName << endl;

139. Quyidagi dastur kodini tahlil qiling:
#include
#include
using namespace std;
class MyDate
{
public:
int year;
int month;
int day;
MyDate()
{
year = 2003;
month = 2;
day = 3;
}
MyDate(int year1, int month1, int day1)
{
year = year1;
month = month1;
day = day1;
}
};
class Name
{
public:
string firstName;
char mi;
string lastName;
MyDate birthDate;
Name(string firstName1, char mi1, string lastName1, MyDate birthDate1)
{
firstName = firstName1;
mi = mi1;
lastName = lastName1;
birthDate = birthDate1;
}
};
int main()
{
MyDate birthDate(1990, 3, 4);
Name name("John", 'F', "Smith", birthDate);
birthDate = MyDate(1991, 1, 2);
birthDate.year = 1992;
cout << name.birthDate.year << endl;
}

140. Quyidagi dastur kodini tahlil qiling:
#include
#include
using namespace std;
class MyDate
{
public:
int year;
int month;
int day;
MyDate()
{
year = 2003;
month = 2;
day = 3;
}
MyDate(int year1, int month1, int day1)
{
year = year1;
month = month1;
day = day1;
}
};
class Name
{
public:
string firstName;
char mi;
string lastName;
MyDate birthDate;
Name(string firstName1, char mi1, string lastName1, MyDate& birthDate1)
{
firstName = firstName1;
mi = mi1;
lastName = lastName1;
birthDate = birthDate1;
}
};
int main()
{
MyDate birthDate(1990, 3, 4);
Name name("John", 'F', "Smith", birthDate);
birthDate.year = 1991;
birthDate.year = 1992;
cout << name.birthDate.year << endl;
}

141. Quyidagi dastur kodini tahlil qiling:
#include
#include
using namespace std;
class MyDate
{ public:
int year;
int month;
int day;
MyDate()
{ year = 2003;
month = 2;
day = 3;
}
MyDate(int year1, int month1, int day1)
{
year = year1; month = month1;
day = day1;
}
};
class Name
{
public:
string firstName;
char mi;
string lastName;
MyDate birthDate;

Name(string firstName1, char mi1, string lastName1, MyDate birthDate1)


{
firstName = firstName1;
mi = mi1;
lastName = lastName1;
birthDate = birthDate1;
}
};
int main()
{
MyDate birthDate(1990, 3, 4);
Name name("John", 'F', "Smith", birthDate);
birthDate = MyDate(1991, 1, 2);
birthDate.year = 1992;
cout << name.birthDate.year << endl;
}

142. Quyidagi dastur kodini tahlil qiling:
#include
#include
using namespace std;
class MyDate
{
public:
int year;
int month;
int day;

MyDate()
{


year = 2003;
month = 2;
day = 3;
}
MyDate(int year1, int month1, int day1)
{
year = year1;
month = month1;
day = day1;
}
};
class Name
{
public:
string firstName;
char mi;
string lastName;
MyDate birthDate;
Name(string firstName1, char mi1, string lastName1, MyDate& birthDate1)
{
firstName = firstName1;
mi = mi1;
lastName = lastName1;
birthDate = birthDate1;
}
};
int main()
{
MyDate birthDate(1990, 3, 4);
Name name("John", 'F', "Smith", birthDate);
birthDate.year = 1991;
birthDate.year = 1992;
cout << name.birthDate.year << endl;
}
143. Circle x [10] nomli o’zgaruvchi e’lon qilingan bo’lsa , quyidagi javoblarning qaysi biri to’g’ri?
144. Barcha sinflar uchun umumiy bo'lgan o'zgaruvchilar _______dir.
145. Quyidagi funksiyalarning qays biriga static kalit so’zini qo’shib yozilishi kerak?
#include
using namespace std;

class Test


{
public:
? int square(int n)
{
return n * n;
}
? int getAge()
{
return age;
}
private:
int age;
};

146. Quyidagi kodda qanday hatolik bor?
#include
using namespace std;
class Test
{
public:
static int square(int n)
{
return n * n;
}
int getAge()
{
return age;
}
private:
int age;
};
int main()
{
cout << Test.square(4);
}

147. Quyidagi kodda qanday hatolik bor?
#include
using namespace std;
class Test
{
public:
static int square(int n)
{
return n * n;
}
int getAge()
{
return age;
}
static int k = 5;
private:
int age;
};
int main()
{
cout << Test::square(4);
}

148. Alohida obyektga murojaat qiluvchi funksiya______ deyiladi.
149. Quyidagi javoblarning qaysi biri to’g’ri?

Download 138,54 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   10




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish