Search Placementyogi.com
 

C# Structures - Advanced .NET Objective Questions

1

What is the output of the following C# program?

using System;
namespace PlacementYogi
{
    struct Yogi
    {
        public int a;
    }
    class Bird
    {
        public static void Main()
        {
            Yogi x = new Yogi();
            x.a = 20;
            fly(ref x);
            Console.Write(x.a + " ");
        }
        static void fly(ref Yogi y)
        {
            y.a = 10;
            Console.Write(y.a + " ");
        }
    } 
}
A.

20 20

B.

10 20

C.

20 10

D.

10 10

E.

None of these

See Answer & Explanation Lets Discuss
Correct answer is : D
Explanation

No explanation available. Let's Discuss

 
2

What is the output of the following C# program?

using System;
namespace PlacementYogi
{
    struct Bird
    {
        public string name; 
        public string color; 
        public void Display()
        {
            Console.WriteLine(name + " " + color);
        } 
        Bird()
        {
            name = "Parrot";
            color = "Green";
        } 
    }
    public class TestBird
    {
        static void Main(string[] args)
        {
            Bird b = new Bird();
            b.Display();
        }
    }
}
A.

Parrot Green

B.

Green Parrot

C.

Compilation Error

D.

None of these

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

0-parameterized constructors are not allowed in structures.

Error printed will be as below:

Structs cannot contain explicit parameterless constructors

 
 

Banner to LogicGuns.com

Hide Page Information

C# Structures - Advanced Objective Questions and Answers with Explanation

Here you can find advanced level C# structures interview questions with answers and explanation.

Why Structures in C#?

In this section you can learn and practice different types of advanced level questions with answers on structures to improve your skills in order to face the interviews, competitive examinations and various entrance tests with full confidence.

Where can I get C# Structures Advanced Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved advanced level structures questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand. All students, freshers can download quiz questions with answers as PDF files and eBooks.

Where can I get Advanced Level C# Structures Interview Questions and Answers (objective type, multiple choice)?

Here you can find objective type advanced structures questions and answers for interview and entrance examination. Multiple choice and TRUE or FALSE type and YES or NO type questions are also provided.