IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C++ Programming C# Programming Java Programming
Microbiology Biochemistry Biotechnology Biochemical Engineering
Civil Engineering Mechanical Engineering Chemical Engineering Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C# Programming - Control Instructions

@ : Home > C# Programming > Control Instructions > General Questions

Exercise

  • General Questions
"I never think of the future. It comes soon enough."
- Albert Einstein
1. 

What does the following C#.NET code snippet will print?

int i = 0, j = 0; 

label:
    i++;
    j+=i;
if (i < 10)
{
    Console.Write(i +" ");
    goto label; 
}

A. Prints 1 to 9
B. Prints 0 to 8
C. Prints 2 to 8
D. Prints 2 to 9
E. Compile error at label:.

2. 

Which of the following is the correct output for the C#.NET program given below?

int i = 20 ;
for( ; ; )
{
    Console.Write(i + " "); 
    if (i >= -10)
        i -= 4; 
    else 
        break;
}

A. 20 16 12 84 0 -4 -8
B. 20 16 12 8 4 0
C. 20 16 12 8 4 0 -4 -8 -12
D. 16 12 8 4 0
E. 16 8 0 -8

3. 

Which of the following statements is correct?

A. It is not possible to extend the if statement to handle multiple conditions using the else-if arrangement.
B. The switch statement can include any number of case instances with two case statements having the same value.
C. A jump statement such as a break is required after each case block excluding the last block if it is a default statement.
D. The if statement selects a statement for execution based on the value of a Boolean expression.
E. C# always supports an implicit fall through from one case label to another.

4. 

What is the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    public enum color
    { red, green, blue };
    
    class SampleProgram
    {
        static void Main (string[ ] args)
        {
            color c = color.blue;
            switch (c)
            {
                case color.red:
                    Console.WriteLine(color.red); 
                    break; 
                
                case color.green: 
                    Console.WriteLine(color.green); 
                    break; 
                
                case color.blue: 
                    Console.WriteLine(color.blue); 
                    break; 
            } 
        } 
    } 
}

A. redB. blue
C. 0D. 1
E. 2

5. 

Which of the following is the correct way to rewrite the following C#.NET code snippet given below?

int i = 0; 
do
{
    Console.WriteLine(i);
    i+ = 1; 
} while (i <= 10);

A.
int i = 0; 
do
{
    Console.WriteLine(i);
} until (i <= 10);
B.
int i;
for (i = 0; i <= 10 ; i++)
    Console.WriteLine(i);
C.
int i = 0; 
while (i <= 11)
{
    Console.WriteLine(i);
    i += 1; 
}
D.
int i = 0;
do while ( i <= 10)
{
    Console.WriteLine(i); 
    i += 1;
}
E.
int i = 0;
do until (i <= 10)
{
    Console.WriteLine(i);
    i+=1; 
}



© 2008-2013 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!