C# Interview Questions - 24 | Snaprecruit.com

C# Interview Questions - 24 | Snaprecruit.com

C SHARP interview questions part 24

C SHARP interview questions part 24

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

Total Questions: 20

1. Correct Output for the given set of programming code is : class Program{ static void Main(string[] args) { int i ; for (i = 0; i < 5; i++) { Console.WriteLine(i); } Console.ReadLine(); }}

Correct Answer is : Derived method

2. Correct Output for the given set of programming code is : class Program { static void Main(string[] args) { int i; for ( i = 0; i < 5; i++) {  } Console. WriteLine(i); Console. ReadLine(); }}

Correct Answer is : Derived method

3. Correct Output for the given set of programming code is : class Program { static void Main(string[] args) { int i ; for ( i = 0; i < 5; i++) { int j = 0; j += i; Console. WriteLine(j); } Console. WriteLine(i); Console. ReadLine(); } }

Correct Answer is : all of the mentioned

4. Correct Output for the given set of programming code is : static void Main(string[] args) { int i ; for (i = 0; i < 5; i++) { int j = 0; j += i; Console. WriteLine(j); } Console. WriteLine( i * j); Console. ReadLine(); }

Correct Answer is : Function overloading

5. Scope of variable is related to definition of variable as: 1. Region of code within which variable value is valid and hence can be accessed. 2. No, relation with region where variable is declared its value is valid in entire scope. a) a b) b c) a, b d) None of the mentioned

Correct Answer is : static method

6. Select the correct output for the following programming code class Program { public static void Main(string[] args) { int i = 100; for (a = 0; a < 5; a++) { int i = 200; Console. WriteLine(a * i); } Console. ReadLine(); } }

Correct Answer is : All of the mentioned

7. Syntax for declaration and initialization of data variable is : a) = ; b) ; c) ; d) = ;

Correct Answer is : all of the mentioned

8. Select the correct output for the following set of code : class Program { public static void Main(string[] args) { int i, j; i = (j = 5) + 10; Console. WriteLine(i); Console. WriteLine(j); Console. ReadLine(); } }

Correct Answer is : 6

9. Choose effective differences between ‘Boxing’ and ‘Unboxing’.

Correct Answer is : TRUE

10. Select differences between reference type and value type : 1. Memory allocated to ‘Value type’ is from heap and reference type is from ‘System. ValueType’ 2. Memory allocated to ‘Value type’ is from ‘System. ValueType’ and reference type is from ‘Heap’ 3. Structures, enumerated types derived from ‘System. ValueType’ are created on stack, hence known as ValueType and all ‘classes’ are reference type because values are stored on heap a) 1, 3 b) 2, 3 c) 1, 2, 3 d) 1

Correct Answer is : TRUE

11. Correct output for the following set of code is : public static void Main(string[] args) { int i = 123; object o = i; i = 456; System. Console. WriteLine("The value-type value = {0}", i); System. Console. WriteLine("The object-type value = {0}", o); Console. ReadLine(); } a) 123, 123 b) 456, 123 c) 456, 456 d) 123, 456

Correct Answer is : 5

12. Correct output for the following set of code is : public static void Main(string[] args) { int i = 546; object o = i; int n =(int) o; o = 70; System. Console. WriteLine("The value-type value = {0}", n); System. Console. WriteLine("The object-type value = {0}", o); Console. ReadLine(); }

Correct Answer is : 2

13. Which of these methods of class String is used to separate a substring from a String object?

Correct Answer is : 25 125

14. What will be the output for the given set of code? static void Main(string[] args) { String a = "Ilove"; String b = "CSHARP"; b = string.Concat(a, ' ', b); Console.WriteLine(b); Console.ReadLine(); }

Correct Answer is : C# allows a function to have arguments with default values

15. Which of these methods of class are used to remove the leading and backward whitespaces?

Correct Answer is : 38080

16. What will be the output for the given set of code? static void Main(string[] args) { String a = "Ilove"; String b = "CSHARP"; b = string.Concat(a,' ',b); string d = b.TrimStart('I', 'l', 'o', 'H'); Console.WriteLine(d); Console.ReadLine(); }

Correct Answer is : Stack overflow exception

17. What will be the output for the given set of code? static void Main(string[] args) { String c = " Hello Computer "; String a = c.Trim(); Console.WriteLine("\"" + s + "\""); }

Correct Answer is : static decimal fun(int i, single, double k)

18. What will be the output for the given set of code? static void Main(string[] args) { String c = "Hello"; String a = c + "Bye"; Console.WriteLine(a); Console.ReadLine(); }

Correct Answer is : 10

19. What will be the output for the given set of code? static void Main(string[] args){ String c = "Hello"; String a ; a = c.Replace('l', 'w'); Console.WriteLine(a); Console.ReadLine();}

Correct Answer is : 1

20. What will be the output of the given code snippet? static void Main(string[] args) { String c = "Hello i love you"; String a ; a = c.Substring(12, 3); Console.WriteLine(a); Console.ReadLine(); }

Correct Answer is : Stack overflow exception

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon