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.
Which statement is correct among the mentioned statements? 1. The for loop works faster than a while loop 2. for( ; ; )implements an infinite loop
Only 1 is correct
Only 2 is correct
Both 1 and 2 are correct
Both 1 and 2 are incorrect
Answer: Option (B)
Which of the following is not infinite loop?
for( ;’0′; )
for( ;’1′; )
Select the output for the following set of code :
staticvoid Main(string[] args)
{
int i =-10;
for(;Convert.ToBoolean(Convert.ToInt32(i));
Console.WriteLine(i++));
Console.ReadLine();
}
-9 -8 -7 -6 -5 -4 -3 -2 -1
-10 -9 -8 -7 -6 -5 -4 -3 -2
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1
-8 -7 -6 -5 -4 -3 -2 -1
for first value of i = -10.Condition is executed until i!=0. Output: -10 -9 -8 -7 -6 -5 -4 -3 -2 -1.
int i, j;
for(i =1, j = i; i <=3&& j >=0; i++, j--)
if(i == j)
continue;
else
Console.WriteLine(j);
i = 0, j = 1;
i = 1, j = 0;
j = 0;
None of the mentioned.
Since for i = 1, j = 1 and 1 <= 3 also 1 >= 0 we had i == j.But after i++ and j–. The initial value of ‘j’ which is ‘0’ as j– preferred other than value of ‘j’ in i = j. Output: j = 0.
int i;
Console.WriteLine("Hi");
for(i =1; i <=10; i++)
Program.Main(args);
Prints ‘Hi’ for one time
Prints ‘Hi’ for infinite times
Stack overflow exception Condition generated
None of above mentioned
Ocurrence of ‘main()’ condition after for loop. Output: Hi Hi . . stack overflow exception.
Select the output for the following set of code:
int i, s =0;
for(i =1; i <=10; s = s + i, i++);
Console.WriteLine(s);
Code report error
Code runs in infinite loop condition
Code gives output as 0 1 3 6 10 15 21 28 36 45
Code give output as 55
Since occurrence of termination symbol(;) at end of for loop. Output: 55.
float f;
for(f = 0.1f; f <=0.5; f +=1)
Console.WriteLine(++f );
1.1
0.1
0.1 0.2 0.3 0.4 0.5
f =0.1 and ++f = 0.1+1 = 1.1.So,1.1>0.5,Condition fails and hence loop terminates. Output : 1.1
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