C SHARP interview questions part 29

C SHARP interview questions part 29

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. Consider an integer pointer . *a.++*a will increment ___________ while *a++ will increment __________

Correct Answer is : Encapsulation

2. What will be the output of the given code snippet? class UnsafeCode{ unsafe static void Main() { int* a; int a1 = 10; int b1; b1 = *&a1; a = &b1; { Console.WriteLine(*a); Console.ReadLine(); } }}

Correct Answer is : Compile time error

3. What will be the output of the code snippet? class UnsafeCode{ unsafe static void Main() { int n = 10; int* p = &n; int** p1 = &p; int*** p2 = &p1; Console.WriteLine(*p * **p1 * ***p2); Console.ReadLine(); }}

Correct Answer is : 45421

4. What will be the output of the following code snippet? class UnsafeCode{ unsafe static void Main() { int* p; p = (int*)(65535); Console.WriteLine((uint)p); Console.ReadLine(); }}

Correct Answer is : 40, 12

5. What does URL stand for?

Correct Answer is : public, private, protected, internal, protected internal

6. Which of these exceptions is thrown by the URL class’s constructors?

Correct Answer is : The base class member functions can access public member functions of derived class

7. What does the following form define? Protocol://HostName/FilePath?Query

Correct Answer is : private

8. Which of these classes is used to encapsulate IP address and DNS?

Correct Answer is : I/O Exception

9. Which of these is a standard for communicating multimedia content over email?

Correct Answer is : read()

10. What does the following method specify? public static WebRequest Create(string requestUriString)

Correct Answer is : readLine()

11. What does the following code display while execution? class Program { static void Main(string[] args) { int ch; HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.McGraw-Hill.com"); HttpWebResponse resp = (HttpWebResponse) req.GetResponse(); Stream istrm = resp.GetResponseStream(); for (int i = 1 ; ;i++) { ch = istrm.ReadByte(); if (ch == -1) break; Console.Write((char)ch); if ((i % 400) == 0) { Console.Write("\nPress Enter."); Console.ReadLine(); } } resp.Close(); } }

Correct Answer is : StringWriter

12. What does the following code display while execution? class Program { static void Main(string[] args) { Uri obj = new Uri("https://www.sanfoundry.com/csharpmcq"); Console.WriteLine(obj.AbsoluteUri); Console.ReadLine(); } }

Correct Answer is : ReadKey()

13. Which of these data members of HttpResponse class is used to store the response from a http server?

Correct Answer is : I/O EXCEPTION ERROR

14. Which of these classes is used to access actual bits or content information of a URL?

Correct Answer is : Run time error

15. What is output for the following code snippet? class Program { static void Main(string[] args) { int i = 5; int j; method1(ref i); method2(out j); Console.writeline(i + " " + j); } static void method1(ref int x) { x = x + x; } static void method2(out int x) { x = 6; x = x * x; } }

Correct Answer is : ReadByte()

16. Statements about ‘ref’ keyword used in C#.NET are?

Correct Answer is : InputOutputStream

17. What will be the output for the given set of code? static void main(string[] args) { int n = 1; method(n); console.Writeline(n); method1(ref n); console.Writeline(n); } static void method(int num) { num += 20; console.writeline(num); } static void method1(ref int num) { num += 20; console.writeline(num); }

Correct Answer is : Read()

18. Which method does following set of code explains? static void Main(string[] args) { int a = 10, b = 20; method(ref a, ref b); console.writeline(a + " " + b); } static void swap(ref int i, ref int j) { int t; t = i; i = j; j = t; }

Correct Answer is : Recursion is a process of defining a method that calls itself repeatedly

19. What will be the output for the given set of code? static void main(string[] args) { int []arr = new int[]{ 1, 2, 3, 4, 5}; fun (ref arr); for (int i = 0; i < arr.Length ; i++) Console.WriteLine( arr[i] + " "); } static void fun(ref int[]a) { a = new int[6]; a[3] = 32; a[1] = 24; }

Correct Answer is : Infinite loop condition occurrence

20. What will be the output of given set of code? static void main(string[] args) { int i; int res = fun (out i); console.writeline(res); console.readline(); } static int fun(out int i) { int s = 1; i = 7; for (int j = 1; j <= i; j++ ) s = s * j; return s; }

Correct Answer is : Recursion is always managed by C# Runtime environment

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon