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
When does a structure variable get destroyed?
When no reference refers to it,it will get garbage collected
Depends on whether it is created using new or without new operator
As variable goes out of the scope
Depends on either we free its memory using free() or delete()
Answer: Option (C)
Which of the following is the correct output for the C#.NET program code given below?
{
struct abc
publicint i;
}
class Program
staticvoid Main(string[] args)
sample a =new sample();
a.i=10;
fun(ref a);
Console.WriteLine(a.i);
publicstatic voidn fun(ref sample x)
x.i=20;
Console.WriteLine(x.i);
10
20
Output – 20 20
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)
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