wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C# .Net Arrays and Split String Method

Total questions: 25

Worksheet time: 25mins

Name
Class
Date
1.

Which of the following items is an example of Camel Case Naming Convention?

a)

lastName

b)

FirstName

c)

middle_name

d)

Firstnumber

2.

Which of the following is considered as a correct format in declaring an Array?

a)

string[ ] myStrings;

b)

string[4] myStrings;

c)

string myStrings[ ];

d)

string( ) myStrings;

3.

Which of the following is considered as a correct format in declaring the SIZE of an Array?

a)

lotteryNumbers = new int[4];

b)

lotteryNumbers[4] = new int[ ];

c)

lotteryNumbers[4] = new int[4];

d)

lotteryNumbers = new[4] int;

4.

Which of the following is considered as a correct format in declaring and setting the size of an Array in a single line?

a)

float[] myFloatValues = new float[10];

b)

float[10] myFloatValues = new float[ ];

c)

float myFloatValues[10] = new float[ ];

d)

float myFloatValues = new[10] float;

5.

int[] lotteryNumbers = new int[4];

lotteryNumbers[0] = 1;

lotteryNumbers[1] = 2;

lotteryNumbers[2] = 3;

lotteryNumbers[3] = 4;


From the above Array example, what is the index of the third integer?

a)

2

b)

0

c)

1

d)

3

6.

Given the example:


int[] lotteryNumbers = new int[8];


What would be the index of the last integer?

a)

7

b)

6

c)

5

d)

8

7.

Given the example:


int[] lotteryNumbers = new int[4] {1, 2, 3, 4};


Which part declares the Array?

a)

int[] lotteryNumbers

b)

lotteryNumbers

c)

new int[4]

d)

{1, 2, 3, 4};

8.

Given the example:


int[] lotteryNumbers = new int[4] {1, 2, 3, 4};


Which part sets the size the Array?

a)

int[] lotteryNumbers

b)

lotteryNumbers

c)

new int[4]

d)

{1, 2, 3, 4};

9.

Given the example:


int[] lotteryNumbers = new int[4] {1, 2, 3, 4};


Which part assigns the values to be saved in the Array?

a)

int[] lotteryNumbers

b)

lotteryNumbers

c)

new int[4]

d)

{1, 2, 3, 4};

10.

Which of the following items identifies the size of an Array?

a)

Length - 1

b)

Size - 1

c)

Array - 1

d)

Int - 1

11.

Which of the following items is an example of Pascal Case Naming Convention?

a)

lastName

b)

FirstName

c)

middle_name

d)

Firstnumber

12.

Using the simplest Split method, how many values will our Array have after splitting the example string below?


string data = "there is a cat";

a)

3

b)

4

c)

5

d)

None

13.

Which of the following split method is can be used to separate a string based on multiple characters?

a)

Regex.Split

b)

File.ReadAllLines

c)

StringSplitOptions.None

d)

StringSplitOptions.RemoveEmptyEntries

14.

Which of the following split method is can be used to split lines in files?

a)

Regex.Split

b)

File.ReadAllLines

c)

StringSplitOptions.None

d)

StringSplitOptions.RemoveEmptyEntries

15.

string value1 = "man,woman,child,,,bird";

char[] delimiter1 = new char[] { ',' };


Which of the following method will result to:


man

woman

child


bird

a)

Regex.Split

b)

File.ReadAllLines

c)

StringSplitOptions.None

d)

StringSplitOptions.RemoveEmptyEntries

16.

string value1 = "man,woman,child,,,bird";

char[] delimiter1 = new char[] { ',' };


Which of the following method will result to:


man

woman

child

bird

a)

Regex.Split

b)

File.ReadAllLines

c)

StringSplitOptions.None

d)

StringSplitOptions.RemoveEmptyEntries

17.

Which of the following iteration statement is can be used to display values from a string Array?

a)

while loop

b)

for loop

c)

foreach loop

d)

both for loop and foreach loop

18.

True or False.


Without the use of an Array, a single variable can only hold one value at a time.

a)

True

b)

False

19.

Which of the following does not belong to the group?

a)

Single Dimensional Array

b)

Multidimensional Array

c)

Jagged Array

d)

Multiple Array

20.

Which of the following is a multidimensional Array?

a)

array anarray[20][20];

b)

int anarray[20][20];

c)

int array[20, 20];

d)

char array[20];

21.

Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?

a)

foo[6];

b)

foo[7];

c)

foo(7);

d)

foo;

22.

What are the legal indexes for the array ar, given the following declaration:


int[] ar = {2, 4, 6, 8 }

a)

0, 1, 2, 3

b)

1, 2, 3, 4

c)

2, 4, 6, 8

d)

0, 2, 4. 6

23.

What is the output of the following code fragment:

int[] ar = {2, 4, 6, 8 };

ar[0] = 23;

ar[3] = ar[1];


Console.ReadLine( ar[0] + " " + ar[3] );

a)

23 2

b)

2 8

c)

3 1

d)

23 4

24.

What is the output of the following code fragment:

int[] z = new int[9];

z[0] = 7;

z[1] = 3;

z[2] = 4;


Console.ReadLine( z[0] + z[1] + " " + z[5] );

a)

10 0

b)

7 3 0

c)

The program is defective and will not compile

d)

7 3 4

25.

What is the output of the following code fragment:

int[] zip = new int[5];

zip[0] = 7;

zip[1] = 3;

zip[2] = 4;

zip[3] = 1;

zip[4] = 9;


Console.ReadLine( zip[ 2 + 1 ] );

a)

4 3

b)

3 7

c)

4

d)

1