Properties



1. A property can be declared inside a class, struct, Interface.  

  • A) True
  • B) False


2. Which of the following statements is correct about properties used in C#.NET?  

  • A) A property can simultaneously be read only or write only.
  • B) A write only property will have only get accessor.
  • C) A write only property will always return a value.
  • D) A property can be either read only or write only.
  • E) All of these.


3. Which one of the following statements is correct?  

  • A) Array elements can be of integer type only.
  • B) The rank of an Array is the total number of elements it can contain.
  • C) The length of an Array is the number of dimensions in the Array.
  • D) The default value of numeric array elements is zero.
  • E) The Array elements are guaranteed to be sorted.


4. Which of the following statements are correct about arrays used in C#.NET?  

  • A) Arrays can be rectangular or jagged.
  • B) Rectangular arrays have similar rows stored in adjacent memory locations.
  • C) Jagged arrays do not have an access to the methods of System.Array Class.
  • D) Rectangular arrays do not have an access to the methods of System.Array Class.
  • E) Jagged arrays have dissimilar rows stored in non-adjacent memory locations.



5. Which properties are used to bind a DataGridView control?  

The DataSource property and the DataMember property are used to bind a DataGridView control.


6. What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?  

We must set the DataSource property and call the DataBind() method.


7. Can we have different access modifiers on get/set methods of a property ?  

No we cannot have different modifiers same property. The access modifier on a property applies to both its get and set accessors.


8. Explain Property in brief  

Besides variable and method members in C# you can define another type of member. It is called property. Properties are members of the class that can be used to access its private data members. Example: class Student { private string stnumber; private string stname; private string stsex; public void setnumber() { Console.WriteLine("Enter student's number:"); stnumber =Console.ReadLine(); } public void getnumber() { Console.WriteLine("Student's number is:{0}",stnumber); } public string stunumber{ //stunumber property set { stnumber=value;} get { return stnumber; } } } A property can be wriable or readable or both. The set keyword defines a wriable property. The get keyword defines readability of the property. By putting both keywords together the property will be both writable and readable.


Java Interview Question

.Net Interview Question

PHP Interview Question

AngularJS Interview Questions