C# Interview Questions - 23 | Snaprecruit.com

C# Interview Questions - 23 | Snaprecruit.com

C SHARP interview questions part 23

C SHARP interview questions part 23

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

Total Questions: 20

1. Select the output for the relevant code set : static void Main(string[] args) { int a = 4, b = 5, c = 7, u = 9; int h; h = (Convert.ToInt32(u < b)) + (a + b--) + 2; Console.WriteLine(h); Console.WriteLine(b); Console.WriteLine(u < b); }

Correct Answer is : method 1:

2. Which among the given classes provides types of rounding functions?

Correct Answer is : Recursion

3. Which of these methods is a rounding function of Math class?

Correct Answer is : 20

4. Which of these method returns a smallest whole number greater than or equal to variable X?

Correct Answer is : 190, 26

5. Which of these methods return a largest whole number less than or equal to variable X?

Correct Answer is : 90, 100, 12

6. Which of the following functions return absolute value of a variable?

Correct Answer is : 25 100000 12.34

7. What will be the output of the given code snippet? class Program{ static void Main(string[] args) { double x = 3.14; int y = (int) Math.Abs(x); Console.WriteLine(y); }}

Correct Answer is : virtual

8. What will be the output of the given code snippet? class Program{ static void Main(string[] args) { double x = 3.14; int y = (int) Math.Ceiling(x); Console.WriteLine(y); }}

Correct Answer is : virtual

9. What will be the output of the given code snippet? class Program{ static void Main(string[] args) { double x = 3.14; int y = (int) Math.Floor(x); Console.WriteLine(y); }}

Correct Answer is : Method overriding

10. Which mechanism among the following helps in identifying a type during the execution of a program?

Correct Answer is : Method overriding

11. Select the statement which are correct about RTTI(Runtime type identification):

Correct Answer is : Sealed

12. Select the Keyword which supports the run time type identification:

Correct Answer is : Sealed

13. What does the following code signify? expr is type

Correct Answer is : When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overridden

14. What will be the output of the given code snippet? class B { }class A : B { }class Program{ static void Main(string[] args) { A a = new A(); B b = new B(); if (a is A) Console.WriteLine("a is an A"); if (b is A) Console.WriteLine("b is an A because it is derived from A"); if (a is B) Console.WriteLine("This won’t display -- a not derived from B"); Console.ReadLine(); }}

Correct Answer is : When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overridden

15. Which operator among the following supports the operation of conversion at runtime without generating the exceptions?

Correct Answer is : 2

16. Which operator among the following is used to perform the operation of boxing, unboxing, reference and identity conversions?

Correct Answer is : 2

17. What will be the output of the given code snippet? class A {}class B : A {}class CheckCast { static void Main() { A a = new A(); B b = new B(); b = a as B; b = null; if(b==null) Console.WriteLine("The cast in b = (B) a is NOT allowed."); else Console.WriteLine("The cast in b = (B) a is allowed"); }}

Correct Answer is : A, B

18. Which operator among the following supplies the information about characteristics of a typeof?

Correct Answer is : A, B

19. What will be the output of the following code snippet? class UseTypeof { static void Main() { Type t = typeof(StreamReader); Console.WriteLine(t.FullName); if(t.IsClass) Console.WriteLine("Is a class."); if(t.IsAbstract) Console.WriteLine("Is abstract."); else Console.WriteLine("Is concrete."); }}

Correct Answer is : New

20. Choose the correct type of variable scope for the given defined variables. class ABC { static int m; int n; void fun (int x , ref int y, out int z, int[] a) { int j = 10; } } Scope declaration:

Correct Answer is : New

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon