Home »
Aptitude Questions and Answers »
C# Aptitude Questions and Answers
C# Arrays Aptitude Questions and Answers | Set 1
C# Arrays Aptitude Questions | Set 1: This section contains aptitude questions and answers on C# Arrays.
Submitted by Nidhi, on April 01, 2020
1) There are following statements are given below, which of them are correct about arrays in C#.NET?
- Arrays are not available in C#.NET
- An array is a group of similar data elements.
- We can create an array for integers, doubles, bytes, strings, etc.
- In C#.Net, Array is a predefined class.
Options:
- Only A
- Only B
- B, C, and D
- Only C
Correct answer: 3
B, C, and D
B, C and D are correct about arrays in C#.
2) Is it possible to create an array of objects?
- Yes
- No
Correct answer: 1
Yes
Yes, we can create an array of objects in C#.NET.
3) What is the correct way to declare and initialize an array of characters with 4 elements?
- char []ch = { 'A', 'C', 'D', 'E'};
- char ch[] = { 'A', 'C', 'D', 'E'};
- char ch{} = { 'A', 'C', 'D', 'E'};
- char ()ch = { 'A', 'C', 'D', 'E'};
Options:
- A
- B
- C
- D
Correct answer: 1
A
char []ch = { 'A', 'C', 'D', 'E'}; is the correct way to declare and initialize an array of characters.
4) There are following statements are given below, which of them are correct about given code snippet in C#.NET?
int []arr = {5,0,10,20,4};
- It is not a proper way to create an array.
- Here we are creating an array of 5 integer elements.
- Here arr is a reference to the array created on the stack.
- We need to use curly braces to create an array in C#.NET.
Options:
- Only A
- Only B
- C and D
- A and D
Correct answer: 2
Only B
Only B is the correct statement about given code snippets.
5) Can we create a jagged array in C#.NET?
- Yes
- No
Correct answer: 1
Yes
Yes, we create a jagged array in C#.NET, in jagged array row size may differ from each other in the matrix.