asya georgieva telerik software academy academy.telerik.com qa trainer
TRANSCRIPT
C# Test Preparation
Asya Georgieva
Telerik Software Academyacademy.telerik.com
QA Trainer
http://telerikacademy.com
Introduction to Programming
Question Indicate the incorrect purpose of the Framework Class Library (FCL)?a) Provides functionality for creating
console applicationsb) Provides functionality for creating
WPF and Silverlight rich-media applications
c) Provides functionality for creating iOS and Android applications
d) Provides functionality for creating Windows Forms GUI applications
e) Provides functionality for creating web applications (dynamic Web sites)
3
Question Indicate the incorrect purpose of the Visual Studio IDE?
a) Edit imagesb) Design user interfacec) Write code in many languagesd) Execute / test / debug applicationse) Browse help and webf) Edit excel documentsg) Manage project's files
4
Primitive Data Typesand Variables
Question
What will the following code result in?
6
char zero = '0';char one = '1';char two = '2';char three = '3';char four = '4';char five = '5';char six = '6';char seven = '7';char eight = '8';char nine = '9'; string ns = (nine + two + five).ToString();int n = ((nine - '0') * 10 + two - '0') * 10 + five - '0';Console.WriteLine(n == ns);
a) Trueb) Falsec) 925d) 1850e) Run-
time error
f) 0g) Compile
time error
Answer What will the following code result in?
7
char zero = '0';char one = '1';char two = '2';char three = '3';char four = '4';char five = '5';char six = '6';char seven = '7';char eight = '8';char nine = '9'; string ns = (nine + two + five).ToString();int n = ((nine - '0') * 10 + two - '0') * 10 + five - '0';Console.WriteLine(n.ToString() == ns);
int type should be converted
to string
Question
What will the following code result in?
8
int i = 0x10; int j = 0x2;Console.WriteLine(i<<j);
d) Compilation error
e)32f)64
a)1b)2c) Run-time
error
162
Question
What will the following code result in?
9
string str = @"\\//\""\'\""";Console.WriteLine(str);
e) \//"'"f) \\/"'"g) Compilation
errorh) Run-time
error
a) \\//\"\'\"b) \//"'"c) \/"'"d) \\//"'"
Question
What will the following code result in?
10
double a = 0.2;decimal b = 0.3m;Console.WriteLine(a+b);
d) Compilation error
e) Run-time error
a)0b)0.5c) null
Question
What will the following code result in?
11
string a = "1";long b = 1L;Console.WriteLine(b + a);
d)2e) Compilation
errorf) Run-time
error
a)11b)11Lc)1L1
Operators, Expressions
and Statements
Question What will the following code result in?
13
byte number = 0;for (int i = 0; i <= 32; i++){ number >>= i; for (int j = 0; j >= -32; j--) { number <<= Math.Abs(j); }}Console.WriteLine(number);
e)2f)255g) Compilation
errorh) Run-time error
a) 0b) 1c) Trued) False
0 shifted left/right is
always 0
Question What will the following code result in?
14
byte b1 = 1;int i1 = 2; int result1 = b1 << i1;int result2 = i1 << b1;int result3 = (i1 + b1) << (i1 - b1);Console.WriteLine("{0}, {1}, {2}", result1, result2, result3);
f) 4, 4, 6g) 6, 6, 6h) 0, 0, 0i) 1, 1, 1j) 4, 4, 2
a) 4, 6, 4b) 4, 6, 6c) 6, 6, 4d) 6, 4, 4 e) 4, 4, 4
Question What will the following code result in?
15
double first = 0.0f;double second = 0.0; for (int i = 0; i < 12; i++){ first += 0.1;} for (int i = 0; i < 4; i++){ second += 0.3;}Console.WriteLine(first==second);
a) 1b) 0 c) 2147483647d) –2147483647e) Truef) Falseg) Compile time
errorh) 3.402823E+38i) -3.402823E+38
1.2 1.2
Question What will the following code result in?
16
int n1 = 4;int n2 = 6;int n3 = 8;int result1 = n1 ^ n2 & n3;int result2 = (n1 ^ n2) & n3;int result3 = n1 ^ (n2 & n3); bool equal12 = result1 == result2;bool equal13 = result1 == result3;bool equal23 = result2 == result3;Console.WriteLine("{0}, {1}, {2}", equal12, equal13, equal23);
a) True, True, True
b) True, True, False
c) True, False, True
d) True, False, False
e) False, True, True
f) False, False, True
g) False, False, False
h) False, True, False
i) Compilation error
j) Run-time error
100110
1000
4
04
Bitwise AND has higher
priority than bitwise XOR
Question What will the following code result in?
17
int a = 3;int b = 5;int result = a+++ ++b;Console.WriteLine("{0} {1} {2}", ++a, b++, --result);
f)5 5 8g)5 6 8h)5 7 8i)5 7 9
a)4 6 9b)4 5 8c)4 6 8d)5 6 9e)Compilation
error
Console Input and Output
Question Indicate the correct statement for the following line of code?
19
Console.Write("Full line{0}", 1, 2);
a) The next print operation will result in a run-time error
b) The next print operation will start on the same line
c) This is an invalid method calld) This print operation will cause run-
time errore) This will cause compilation errorf) There is no Write(…) method in the
Console class
Question Which line of code should be used if we want to ensure that the decimal separator is "."?
20
a) Console.OutputEncoding = Encoding.UTF8;
b) Console.SetDecimalSeparator('.');c) Console.DecimalSeparator = '.';d) Console.CurrentCulture =
CultureInfo.InvariantCulture;e) double.Parse(1.2);f) Thread.CurrentThread.CurrentCulture
= CultureInfo.InvariantCulture;
Question
What will Console.ReadLine() return when there aren't any available lines to read?
a) ""b) "\0"c) '\0'd) nulle) Compile time errorf) Run-time error
21
Question How many consecutive intervals will
be printed between the two digits (1 and 2) after the execution of the following code?
22
int a = 1;int b = 2;Console.Write("{0,-10}{1,10}", a, b);
a) 0b) 20c) 14d) 10e) 18f) This code will cause run-time
error
Conditional Statements
Question What will the following code result in?
24
bool isTrue = true;bool isFalse = false;if (!!(!(isTrue && isFalse) || !(isTrue || isFalse))){ Console.WriteLine(isFalse);}else{ Console.WriteLine(isTrue);}
e) Compilation error
f) Runtime errorg) None of the
answers
a) falseb) True c) trued) False
Question What will the following code result in?
25
int i = 1;int j = 1;switch (i){ case 1: i = 1; break; case j: i = 2; break; case i: i = 3; break; default: i = 4; break;}Console.WriteLine(i);
a) 1b) 2 c) 3d) 4e) Compilation
errorf) Run-time errorg) None of the
answers
The case value must be a constant
Question What will the following code result in?
26
int number = 5;if (number++ == ++number){ Console.WriteLine(number + 1);}else{ Console.WriteLine(number + 2);}
e)9f)10g) Compilation
errorh) Run-time error
a)5b)6c)7d)8
Question What will the following code result in?
27
int? number = new int?();switch (number){ case 1: Console.Write(1); break; case 2: Console.Write(2); break; case 3: Console.Write(3); break; case null: Console.Write(4); break; default: Console.Write(5); break;}
a)1b)2 c)3d)4e) Compilation
errorf) Run-time errorg) None of the
answers
Loops
Question What will the following code result in?
29
int count = 0;for (int i = 1, j = 2; i < j; i++, j++){ count++; if (i == 3) i++; break;}Console.WriteLine(count);
e)4f) Compilation
errorg) Run-time errorh) Endless loop
a)0b)1c)2d)3
Question What will be printed on the console when the following code is executed?
30
string[] elements = { "ab", "12" };foreach (var e in elements){ foreach (var ch in e) { Console.Write(ch); } Console.Write(e);}
a) ab12b) 12abc) abab1212d) ab12ab12e) 12ab12abf) Endless
loopg) Run-time
errorh) Compilation
error
Question What will the following code result in?
31
int n = 4, f = 0;do{ f *= n; n--;}while (n > 0);Console.WriteLine(f);
f) 120g) Compilation errorh) Run-time errori) Endless loop
a) 0b) 4c) 6d) 12e) 24
Question
What will the following code result in?
32
for (int i = 1; i <= 4; i = i * 2){ Console.Write(i + " ");}
f) 1 2 4g) Compilation
errorh) Run-time errori) Endless loop
a) 1 2b) 2 4 6c) 2 4 8d) 1 2 3e) 1 2 3 4
Question
What will the following code result in?
33
int sum = 0;while (sum < 10) for (int i = 0; i <= 2; i++) sum += i;Console.WriteLine(sum);
e) 12f) Compilation
errorg) Run-time errorh) Endless loop
a) 0b) 9c) 10d) 11
Question*** Try your luck! What will be written on the console when the following code is executed?
34
int toto = 1;for (int i = 2; i <= 4; i++, toto++){ for (int j = i - 1; j < i + 1; j += 2, toto += i < j ? 1 : -1) { toto <<= 2; }}Console.WriteLine(toto - 57);
e)6f)35g)42h)49
a)-49b)-42c)-35d)5
форум програмиране, форум уеб дизайнкурсове и уроци по програмиране, уеб дизайн – безплатно
програмиране за деца – безплатни курсове и уроцибезплатен SEO курс - оптимизация за търсачки
уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop
уроци по програмиране и уеб дизайн за ученициASP.NET MVC курс – HTML, SQL, C#, .NET, ASP.NET MVC
безплатен курс "Разработка на софтуер в cloud среда"
BG Coder - онлайн състезателна система - online judge
курсове и уроци по програмиране, книги – безплатно от Наков
безплатен курс "Качествен програмен код"
алго академия – състезателно програмиране, състезания
ASP.NET курс - уеб програмиране, бази данни, C#, .NET, ASP.NETкурсове и уроци по програмиране – Телерик академия
курс мобилни приложения с iPhone, Android, WP7, PhoneGap
free C# book, безплатна книга C#, книга Java, книга C#Дончо Минков - сайт за програмиранеНиколай Костов - блог за програмиранеC# курс, програмиране, безплатно
?
? ? ??
?? ?
?
?
?
??
?
?
? ?
Questions?
?
C# Test Preparation
http://academy.telerik.com