Question
class sample
{
public int i;
public int[] arr = new int[10];
public void fun(int i, int val)
{
arr[i] = val;
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample();
s.i = 10;
sample.fun(1, 5);
s.fun(1, 5);
Console.ReadLine();
}
}
a.
sample.fun(1, 5) will not work correctly
b.
s.i = 10 cannot work as i is ‘public’
c.
sample.fun(1, 5) will set value as 5 in arr[1].
d.
s.fun(1, 5) will work correctly
Posted under C# programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. Select output for the following set of code.
Similar Questions
Discover Related MCQs
Q. Which of the following is used to define the member of a class externally?
View solution
Q. The operator used to access member function of a class?
View solution
Q. What is the most specified using class declaration ?
View solution
Q. Which of following statements about objects in “C#” is correct?
View solution
Q. “A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse.In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data.”
View solution
Q. Correct way of declaration of object of the following class is ?
class name
View solution
Q. The data members of a class by default are ?
View solution
Q. What does the following code imply ?
csharp abc;
abc = new charp();
View solution
Q. Which refrence modifier is used to define reference variable?
View solution
Q. Select the wrong statement about ‘ref’ keyword in C#?
View solution
Q. Select correct differences between ‘=’ and ‘==’ in C#.
View solution
Q. What is output for the following set of expression?
int a+= (float) b/= (long)c
View solution
Q. Which of following statements are correct about functions?
View solution
Q. When a function fun() is to receive an int, a single & a double and it is to return a decimal, then the correct way of defining this function is?
View solution
Q. How many values does a function return?
View solution
Q. Which return statement correctly returns the output:
View solution
Q. Number of constructors a class can define is ?
View solution
Q. Correct statement about constructors in C#.NET is ?
View solution
Q. Which among the following is the correct statement :
Constructors are used to
View solution
Q. Can the method add() be overloaded in the following ways in C#?
public int add() { }
public float add(){ }
View solution
Suggested Topics
Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!