adplus-dvertising
frame-decoration

Question

What will be the output of the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{
    class Sample
    { 
        public static void fun1()
        { 
            Console.WriteLine("Bits1 method");
        }
        public void fun2()
        { 
            fun1(); 
            Console.WriteLine("Bits2 method");
        }
        public void fun2(int i)
        { 
            Console.WriteLine(i);
            fun2(); 
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample s = new Sample(); 
            Sample.fun1(); 
            s.fun2(123);
        } 
    } 
}

a.

Bits1 method
123
Bitsl method
Bits2 method

b.

Bits1 method
123
Bits2 method

c.

Bits2 method
123
Bits2 method
Bitsl method

d.

Bitsl method
123

Posted under C# programming

Answer: (a).Bits1 method
123
Bitsl method
Bits2 method

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the C#.NET code snippet given below?

Similar Questions

Discover Related MCQs

Q. Which of the following statements is correct?

Q. The this reference gets created when a member function (non-shared) of a class is called.

Q. Which of the following statements are correct?

1. Data members ofa class are by default public.
2. Data members of a class are by default private.
3. Member functions of a class are by default public.
4. A private function of a class can access a public function within the same class.
5. Member function of a class are by default private.

Q. Which of the following statements are correct about objects of a user-defined class called Sample?

1. All objects of Sample class will always have exactly same data.
2. Objects of Sample class may have same or different data.
3. Whether objects of Sample class will have same or different data depends upon a Project Setting made in Visual Studio.NET.
4. Conceptually, each object of Sample class will have instance data and instance member functions of the Sample class.
5. All objects of Sample class will share one copy of member functions.

Q. Which of the following statements is correct about classes and objects in C#.NET?

Q. Which of the following is used to define the member of a class externally?

Q. The operator used to access member function of a class?

Q. What is the most specified using class declaration ?

Q. Which of following statements about objects in “C#” is correct?

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.”

Q. Correct way of declaration of object of the following class is ?

class name

Q. The data members of a class by default are ?

Q. What does the following code imply ?

csharp abc;
abc = new charp();

Q. Which refrence modifier is used to define reference variable?

Q. Select the wrong statement about ‘ref’ keyword in C#?

Q. Select correct differences between ‘=’ and ‘==’ in C#.

Q. What is output for the following set of expression?

int a+= (float) b/= (long)c

Q. Which of following statements are correct about functions?

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?

Q. How many values does a function return?