Array, String, Regular Expression
Array, String, Regular Expression
1) Which of the following will be the correct output for the C#.NET code snippet given below?
(2pts)
String s1 = Bahir;
String s2;
s2 = s1.Insert(3, Dar Technology);
a) Bahir Dar Technology
d) BahiDar Technologyr
b) BahirDar Technology
e) BahDar Technologyir
c) Bahir Dar Technology
f) None
2) What is the output of the following code?(6pts)
a) int Num1,Num2;
Num1 = 10;
Num2 = 0;
TextBox1.Text = (Num1 / Num2).ToString();
b) int i, LetterCount =0;
String strText ;
String letter = null; ;
strText = "Debugging";
for (i = 1;i< strText.Length-1;i++)
letter = strText.Substring(1,1);
if ( letter.Equals("g") )
LetterCount = LetterCount + 1;
textBox1.Text = "G appears " + LetterCount + " times";
3) Given the following variable declaration: (3pts)
float []results={50,60,45,78,96,84,47,65,89};
Add all array items to the list; named listBox1; using foreach loop
4) Answer the following questions based on the following codes(4pts)
String []array=new String [20];
String strList =Bahir Dar university, Institute of Technology School of
Computing;
array = strList.Split(" ")
a) What is the size of array?
b) List elements of array.
11) Which of the following will be the correct output for the C#.NET code snippet given below?
(3pts)
String s1 = ALL MEN ARE CREATED EQUAL;
String s2;
s2 = s1.Substring(12);
Console.WriteLine(s2);
a) CREATED EQUAL
d) CRE
b) CREATED EQUAL
e) none
c) CREATED
12) Write the meaning of the following quantifier(6pts)
a) *
d) {n}
b) +
e) {n,}
c) ?
f) {n,m}
13) Write matched if the following string matches the given regular expression anf write not
matched if other wise. (3pts)
String regStr=^[a-z]+[@#%][a-z]+$;
a) Abebe@bahir dar
e) abebe#
b) abebe#bahir dar
f) @bahir dar
c) abebe%bahir dar
g) What is your name?
d) @
h) !@#$
14) Write matched if the following string matches the given regular expression anf write not
matched if other wise. (3pts)
String regStr=[a-z1-9]+;Abebe
a) 123abebe
d) !@#$
b) #abebe
e) <>:{
c) What is your name?
15) Write matched if the following string matches the given regular expression anf write not
matched if other wise. (3pts)
String regStr=^[^<?>,.:;!@#%&*(){}]+$;Abebe
a) 123abebe
d) !@#$
b) #abebe
e) <:>{
c) What is your name?
16) Write regular expression that will be used for the following scenario(6pts)
a) Sequence of character that can be used for C# variable name
b) Begins with sequence of alphabetical letter and followed by sequence of digits or special symbols such
as @#,&*?
c) Consists of sequence of alphabetical letter, digits