Question: Which of the following is the correct way to implement a write only property Length in a Sample class?

Options

A : class Sample { public int Length { set { Length = value ; } } }

B : class Sample { int len; public int Length { get { return len; } set { len = value ; } } }

C : class Sample { int len; public int Length { WriteOnly set { len = value ; } } }

D : class Sample { int len; public int Length { set { len = value ; } } }

Click to view Correct Answer

Previous || Next

Properties - General Questions more questions

Which of the following statements is correct about properties used....

A Student class has a property called rollNo and stu....

If a class Student has an indexer, then which of....

Which of the following statements are correct?

If Sample class has a Length property with get and....

A property can be declared inside a namespace or a....

If a Student class has an indexed property which is....

If Sample class has a Length property with get accessor....

An Account class has a property called accountNo and acc....

Suppose a Student class has an indexed property. This property....

Attributes - General Questions more Online Exam Quiz

Inheritance - General Questions

Interfaces - General Questions

Namespaces - General Questions

Operators - General Questions

Polymorphism - General Questions

Structures - General Questions

Advanced SQL - General Questions

Data and Database Administration - General Questions

Database Design Using Normalization - General Questions

Database Processing for BIS - General Questions