Which of the following statements is correct about the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { public int index; public int[] arr = new int[10]; public void fun(int i, int val) { arr[i] = val; } } class MyProgram { static void Main(string[] args) { Sample s = new Sample(); s.index = 20; Sample.fun(1, 5); s.fun(1, 5); } } }

- Online Exam Test Papers | - MCQs[multiple choice questions and answers ] | - Mock Test Papers | - Practice Papers | - Sample Test Papers |

Question:
Which of the following statements is correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{ 
    class Sample
    { 
        public int index; 
        public int[] arr = new int[10]; 
        
        public void fun(int i, int val)
        { 
            arr[i] = val;
        }
    }
     
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample s = new Sample(); 
            s.index = 20; 
            Sample.fun(1, 5); 
            s.fun(1, 5); 
        } 
    } 
}

1.s.index = 20 will report an error since index is public.

2.The call s.fun(1, 5) will work correctly.

3.Sample.fun(1, 5) will set a value 5 in arr[ 1 ].

4.The call Sample.fun(1, 5) cannot work since fun() is not a shared function.

Posted Date:-2021-02-25 10:32:15


More MCQS Questions and answers

Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!