Home » Aptitude Questions and Answers » C# Aptitude Questions and Answers

C# Properties Aptitude Questions and Answers | Set 2

C# Properties Aptitude Questions | Set 2: This section contains aptitude questions and answers on C# Properties.
Submitted by Nidhi, on April 10, 2020

1) Suppose we have a class Employee, that contains a property called "empId", we want it cannot be changed during the program, and then what needs to do in our program?
  1. Declare empId property with both get and set accessors.
  2. Declare empId property with an only set accessor.
  3. Declare empId property with only get accessor.
  4. Declare empId property with getting, set and final accessors.

2) Can we create more than one property in a class in C#.NET?
  1. Yes
  2. No

3) Suppose we have a class Employee that contains a property called "empId", we want to provide functionality for reading and write both, and then what needs to do in our program?
  1. Declare empId property with both get and set accessors.
  2. Declare empId property with an only set accessor.
  3. Declare empId property with only get accessor.
  4. Declare empId property with getting, set and final accessors.

4) Suppose we have a class Employee, that contains a property called "empId", we want to make it write-only, and then what needs to do in our program?
  1. Declare empId property with both get and set accessors.
  2. Declare empId property with an only set accessor.
  3. Declare empId property with only get accessor.
  4. Declare empId property with getting, set and final accessors.

5) Suppose we have a class Employee that contains a property called "empId" with set and get accessors then which of the following options work properly?
    A.	Employee.empId = 101;
    B.	Employee emp = new Employee();  emp.empId = 101;
    C.	Employee emp = new Employee();  int id = emp.empId; 
    D.	Employee emp = new Employee();  emp.empId = emp.empId + 10; 

Options:

  1. Only A
  2. Only B
  3. B and C
  4. B, C, and D






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.