adplus-dvertising

Welcome to the Miscellaneous Topics MCQs Page

Dive deep into the fascinating world of Miscellaneous Topics with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Miscellaneous Topics, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Miscellaneous Topics, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Miscellaneous Topics. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Miscellaneous Topics. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Miscellaneous Topics MCQs | Page 2 of 17

Q11.
Which of the following statements is correct about the C#.NET code snippet given below?

struct Book
{
    private String name; 
    private int noofpages; 
    private Single price;
}
Book b = new Book();
Discuss
Answer: (d).The structure variable b will be created on the stack.
Q12.
Which of the following will be the correct output for the C#.NET program given below?

namespace CompSciBitsConsoleApplication
{ 
    struct Sample
    { 
        public int i;
    }
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample x = new Sample(); 
            x.i = 10; 
            fun(ref x); 
            Console.Write(x.i + " ");
        }
        public static void fun(ref Sample y)
        { 
            y.i = 20;
            Console.Write(y.i + " "); 
        } 
    } 
}
Discuss
Answer: (d).20 20
Discuss
Answer: (b).All value types in C# inherently derive from ValueType, which inherits from Object.
Q14.
Which of the following statements are correct about the structure declaration given below?

1. We cannot declare the access modifier of totalpages as protected.
2. We cannot declare the access modifier of name as private.
3. We cannot define a zero-argument constructor inside a structure.
4. We cannot declare the access modifier of price as public.
5. We can define a Showdata() method inside a structure.

struct Book
{
    private String name; 
    protected int totalpages; 
    public Single price; 
    public void Showdata()
    {
        Console.WriteLine(name + " " + totalpages + " " + price);
    } 
    Book()
    {
        name = " "; 
        totalpages = 0;
        price = 0.0f; 
    } 
} 
Book b = new Book();
Discuss
Answer: (b).1, 3, 5
Q15.
Which of the following are true about classes and struct?

1. A class is a reference type, whereas a struct is a value type.
2. Objects are created using new, whereas structure variables can be created either using new or without using new.
3. A structure variable will always be created slower than an object.
4. A structure variable will die when it goes out of scope.
5. An object will die when it goes out of scope.
Discuss
Answer: (a).1, 2, 4
Q16.
Which of the following will be the correct output for the program given below?

namespace CompSciBitsConsoleApplication
{ 
    struct Sample
    {
        public int i;
    }
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample x = new Sample();
            Sample y;
            x.i = 9;
            y = x;
            y.i = 5;
            Console.WriteLine(x.i + " " + y.i); 
        } 
    } 
}
Discuss
Answer: (b).9 5
Q17.
Which of the following statements are correct about Structures used in C#.NET?

1. A Structure can be declared within a procedure.
2. Structs can implement an interface but they cannot inherit from another struct.
3. struct members cannot be declared as protected.
4. A Structure can be empty.
5. It is an error to initialize an instance field in a struct.
Discuss
Answer: (b).2, 3, 5
Q18.
The [Serializable()] attribute gets inspected at
Discuss
Answer: (b).Run-time
Discuss
Answer: (d).By applying AttributeUsageAttribute to the custom attribute's class definition.
Q20.
Which of the following are correct ways to pass a parameter to an attribute?

1. By value
2. By reference
3. By address
4. By position
5. By name
Discuss
Answer: (c).4, 5
Page 2 of 17

Suggested Topics

Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!