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
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
Answer: Option (B) and (D)
Select output for the following set of code:
class sample
{
publicint i;
publicint[] arr =newint[10];
publicvoid fun(int i, int val)
arr[i]= val;
}
class Program
staticvoid Main(string[] args)
sample s =new sample();
s.i=10;
sample.fun(1, 5);
s.fun(1, 5);
Console.ReadLine();
sample.fun(1, 5) will not work correctly
s.i = 10 cannot work as i is ‘public’
sample.fun(1, 5) will set value as 5 in arr[1] d) s.fun(1, 5) will work correctly
An Object reference is required for non static field,method or property. i.e sample s = new sample(); s.i = 10; sample.fun(1, 5); sample.fun(1, 5); Console.ReadLine();
The output of code is ?
class test
publicvoid print()
Console.WriteLine("Csharp:");
test t;
t.print();
Code runs successfully prints nothing
Code runs and prints “Csharp”
Syntax error as t is unassigned variable which is never used
None of above mentioned
object of class test should be declared as test t = new test(); test t = new test(); t.print(); Console.ReadLine();
The operator used to access member function of a class?
:
::
.
#
objectname.function name(actual arguments);
Select the output for the following set of code :
publicint j;
publicvoid fun(int i, int j)
this.i= i;
this.j= j;
s.i=1;
s.j=2;
s.fun(s.i, s.j);
Console.WriteLine(s.i+" "+ s.j);
Error while calling s.fun() due to inaccessible level
Error as ‘this’ reference would not be able to call ‘i’ and ‘j’
1 2
Runs successfully but prints nothing
Variable ‘i’ and ‘j’ declared with scope public in sample class are accessed using object of class ‘sample’ which is ‘s’. Output:1 2.
What will be the output of the following snippet of code?
class number
int length =50;
publicint number1
get
return length;
set
length =value;
publicstaticvoid Main(string[] args)
number p =new number();
p.number1= p.number1+40;
int k = p.number1*3/9;
Console.WriteLine(k);
0
180
30
Compile time error
Choose the correct statement among the following?
A property can be a static member whereas an indexer is always an instance member
A get accessor of a property corresponds to a method with no parameters whereas get accessor of an indexer corresponds to a method with the same formal parameters lists as the indexer
It is an error for indexer to declare a local variable with the same name as indexer parameters
All of the mentioned
Answer: Option (D)
Choose the keyword which declares the indexer?
base
this
super
extract
The indexer is declared using the name this.
Choose the operator/operators which is/are used to access the [] operator in indexers?
access
The indexer is implemented through the get and set accessors for the [] operator as: public double this[int idx] { get { if() { } else { return([idx]); }
} set { array[idx];
} }
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