AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Which statement is correct about following c#.NET code ?
int[] a= {11, 3, 5, 9, 6};
’a’ is a reference to the array created on stack
’a’ is a reference to an object created on stack
’a’ is a reference to an object of a class that compiler drives from ‘System.Array’ class
None of the mentioned
A perfect way of defining single array in C# which is derived automatically from class ‘System.Array’
Which statement is correct about following set of code ? int[, ]a={{5, 4, 3},{9, 2, 6}};
’a’ represents 1-D array of 5 integers
a.GetUpperBound(0) gives 9
’a’ represents rectangular array of 2 columns and 3 arrays
a.GetUpperBound(1) gives 2
By definition Options (C) and (D)
What is the advantage of using 2D jagged array over 2D rectangular array?
Easy initialization of elements
Allows unlimited elements as well as rows which had ‘0’ or are empty in nature
All of the mentioned
In many applications where 2 dimensional arrays are used,not all rows need to have all the elements i.e they are sparse.Many rows have 0 elements.In such cases it is better to use 2D jagged arrays as they allow unequal number of elements in each row and also allow for empty rows.
What is the output of the following set of code ?
staticvoid Main(string[] args)
{
int i, j;
int[, ] arr =newint[3, 3];
for(i =0; i <3;++i)
for(j =0; j <3;++j)
arr[i, j]= i *2+ i *2;
Console.WriteLine(arr[i, j]);
}
Console.ReadLine();
0,0,0 4,4,4 8,8,8
4,4,4 8,8,8 12,12,12
8,8,8 12,12,12 16,16,16
0,0,0 1,1,1, 2,2,2
Since,with each value of of ‘i’ the value of ‘j’ is executed three times i.e for i = 0, j = 0, 0, 0, i = 1, j = 2, 2, 2. Output: 0, 0, 0 4, 4, 4 8, 8, 8.
What is the output for the following set of code ?
double a =345.09;
byte c =(byte) a;
Console.WriteLine(c);
98
89
88
84
Type casting a larger variable into a smaller variable results in modules of larger variable by range of smaller variable. a is ‘345.09’ which is larger than byte’s range i:e -128 to 127. Output : 89.
Which is the correct way of defining and initializing an array of 3 integers?
int[] a={78, 9, 54};
int[] a; a = new int[3]; a[1] = 78; a[2] = 9; a[3] = 54;
int[] a; a = new int{78, 9, 54};
int[] a; a = new int[3]{78, 9, 54};
Answer: Option (A) and Option (D)
What is the output for the following set of code?
char A ='K';
char B = Convert.ToChar(76);
A++;
B++;
Console.WriteLine(A+" "+B);
M L
U L
L M
A B
“++” increments the value of character by 1. A and B are given values K and 76, when we use increment operator their values increments by 1, A and B becomes L and M. Output: L, M.
Choose selective differences between an array in c# and array in other programming languages.
Declaring array in C# the square bracket([]) comes after the type but not after identifier
It is not necessary to declare size of an array with its type
No difference between declaration of array in c# as well as as in other programming languages
All of the above mentioned
1. When declaring an array in C#, the square brackets ([]) come after the type, not the identifier.Brackets after the identifier is not legal syntax in C#. example : int[] IntegerArray; 2. The size of the array is not part of its type as it is in the C language. This allows to declare an array and assign any array of int objects to it, regardless of the array’s length. int[] IntegerArray; IntegerArray = new int[10]; IntegerArray = new int[50];
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies