

MCQOPTIONS
Saved Bookmarks
1. |
Select output for the following set of code. 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 |
Answer» B. S.i = 10 cannot work as i is public | |