Functions & Subroutines



1. What will be the output of the C#.NET code snippet given below?
byte b1 = 0xF7;
byte b2 = 0xAB;
byte temp;
temp = (byte)(b1 & b2);
Console.Write (temp + "" "");
temp = (byte)(b1^b2);
Console.WriteLine(temp);
 

  • A) 163 92
  • B) 92 163
  • C) 192 63
  • D) 0 1
  • E) 1 0


2. In C#, a subroutine is called a  

  • A) Function
  • B) Unmanaged code
  • C) Method
  • D) Managed Code
  • E) Metadata


3. Which of the following will be the correct output for the C#.NET program given below?
namespace LazyQuestionConsoleApplication
{ 
    class SampleProgram
    {
        static void Main(string[] args)
        { 
            int num = 1;
            funcv(num); 
            Console.Write(num + ", "); 
            funcr(ref num); 
            Console.Write(num + ", ");
        }
        static void funcv(int num)
        { 
            num = num + 10; Console.Write(num + ", ");
        }
        static void funcr (ref int num)
        { 
            num = num + 10; Console.Write(num + ", ");
        } 
    } 
}
 

  • A) 1,1,1,1,1
  • B) 11, 1, 11, 11,
  • C) 11, 11, 11, 11,
  • D) 11, 11, 21, 11,
  • E) 11, 11, 21, 21,


4. Can events have access modifiers?  

Events are always public as they are meant to serve every one-register ing to it. But you can access modifiers in events. You can have events with protected keyword, which will be accessible only to inherited classes. You can have private events only for object in that class.



5. Do events have return type.  

No, events do not have return type.


6. What is the difference between Finalize() and Dispose() methods?  

Dispose() is called when we want for an object to release any unmanaged resources with them. On the other hand Finalize() is used for the same purpose but it doesn’t assure the garbage collection of an object.


.Net Interview Question

PHP Interview Question

Java Interview Question

AngularJS Interview Questions