AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Where the properties can be declared?
Class
Struct
Interface
Namespace
Answer: Options (A), (B) and (C)
Choose the statements which makes use of essential properties rather than making data member public in C#.NET?
Properties have their own access levels like private, public, protected etc. which allows it to have better control about managing read and write properties
Properties give us control about what values may be assigned to a member variables of a class they represent
Properties consist of set accessor inside which we can validate the value before assigning it to the data variable
All of the above mentioned
Answer: Option (D)
Select the modifiers which can be used with the properties?
Private
Public
Protected Internal
Protected
Answer: Options (A), (B), (C) and (D)
Choose the correct statement about the properties used in C#.NET?
Each property consists of accessor as get and set
A property can be either read or write only
Properties can be used to store and retrieve values to and from the data members of a class
Properties are like actual methods which work like data members
Answer: Option (C) and Option (D)
Choose the correct statements about write-only properties in C#.NET?
Properties which can only be set
Properties once set and hence values cannot be read back in nature
Useful for usage in classes which store sensitive information like password of a user
None of the above mentioned
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the code below to work.Which is the correct solution to ensure this functionality? b.maths = 10; Console.WriteLine(b.maths);
Declare maths property with get and set accessors
Declare maths property with only get accessors
Declare maths property with only set accessors
Declare maths property with only get, set and normal accessors
Answer: Option (A)
Consider a class maths and we had a property called as sum.b which is the reference to a maths object and we want the statement Console.WriteLine(b.sum)to fail.Which among the following is the correct solution to ensure this functionality?
Declares sum property with only get accessor
Declares sum property with only set accessor
Declares sum property with both set and get accessor
Declares sum property with both set, get and normal accessor
Answer: Option (B)
If math class had add property with get and set accessors, then which of the following statements will work correctly?
math.add = 20;
math m = new math(); m.add = 10;
Console.WriteLine(math.add);
math m = new math(); m.add = m.add + 20;
Answer: Option (B) and (D)
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail.Which of the follwing is the correct solution to ensure this functionality?
Declare sum property with both get and set accessors
Declare sum property with get, set and normal accessors
None of the mentioned
Answer: Option (C)
Select the correct statement about properties of read and write in C#.NET?
A property can simultaneously be read or write only
A property can be either read only or write only
A write only property will only have get accessor
A read only property will only have get accessor
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies