C# Programming - Properties

Why should I learn to solve C# Programming questions and answers section on "Properties"?

Learn and practise solving C# Programming questions and answers section on "Properties" to enhance your skills so that you can clear interviews, competitive examinations, and various entrance tests (CAT, GATE, GRE, MAT, bank exams, railway exams, etc.) with full confidence.

Where can I get the C# Programming questions and answers section on "Properties"?

IndiaBIX provides you with numerous C# Programming questions and answers based on "Properties" along with fully solved examples and detailed explanations that will be easy to understand.

Where can I get the C# Programming section on "Properties" MCQ-type interview questions and answers (objective type, multiple choice)?

Here you can find multiple-choice C# Programming questions and answers based on "Properties" for your placement interviews and competitive exams. Objective-type and true-or-false-type questions are given too.

How do I download the C# Programming questions and answers section on "Properties" in PDF format?

You can download the C# Programming quiz questions and answers section on "Properties" as PDF files or eBooks.

How do I solve C# Programming quiz problems based on "Properties"?

You can easily solve C# Programming quiz problems based on "Properties" by practising the given exercises, including shortcuts and tricks.

Exercise : Properties - General Questions
  • Properties - General Questions
1.
A property can be declared inside a class, struct, Interface.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.

2.
Which of the following statements is correct about properties used in C#.NET?
A property can simultaneously be read only or write only.
A property can be either read only or write only.
A write only property will have only get accessor.
A write only property will always return a value.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

3.
A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement stu.RollNo = 28 to fail. Which of the following options will ensure this functionality?
Declare rollNo property with both get and set accessors.
Declare rollNo property with only set accessor.
Declare rollNo property with get, set and normal accessors.
Declare rollNo property with only get accessor.
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.

4.
If a class Student has an indexer, then which of the following is the correct way to declare this indexer to make the C#.NET code snippet given below work successfully?
Student s = new Student(); 
s[1, 2] = 35;
class Student
{ 
    int[ ] a = new int[5, 5]; 
    public property WriteOnly int this[int i, int j]
    { 
        set
        { 
            a[i, j] = value;
        } 
    }
}
class Student
{ 
    int[ , ] a = new int[5, 5]; 
    public int property WriteOnly
    { 
        set
        { 
            a[i, j] = value;
        } 
    } 
}
class Student
{ 
    int[ , ] a = new int[5, 5];
    public int this[int i, int j] 
    {
        set
        { 
            a[i, j] = value;
        } 
    } 
}
class Student
{ 
    int[ , ] a = new int[5, 5];
    int i, j; 
    public int this
    { 
        set
        { 
            a[i, j] = value;
        } 
    } 
}
Answer: Option
Explanation:
No answer description is available. Let's discuss.

5.
Which of the following statements are correct?
  1. The signature of an indexer consists of the number and types of its formal parameters.
  2. Indexers are similar to properties except that their accessors take parameters.
  3. Accessors of interface indexers use modifiers.
  4. The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself.
  5. An interface accessor contains a body.
1, 3, 5
1, 2, 4
3, 5
2, 4
Answer: Option
Explanation:
No answer description is available. Let's discuss.