C# Interview Questions - 21 | Snaprecruit.com

C# Interview Questions - 21 | Snaprecruit.com

C SHARP interview questions part 21

C SHARP interview questions part 21

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

Total Questions: 20

1. What will be the output of the following code? class math { public int a,b; public math(int i, int j) { a = i; b = j; } public void sum(math m) { m.a *= 2; m.b += 2; } } class Program { static void Main(string[] args) { math t = new math(20, 10); t.sum(t); Console.WriteLine(t.a + " " + t.b); Console.ReadLine(); } }

Correct Answer is : int ReadByte()

2. Accessibility modifier defined in a class are?

Correct Answer is : All of the mentioned

3. Choose the statements which are false in nature:

Correct Answer is : Sets the current position in the stream to the specified offset from specified origin and hence returns the new position

4. Which of these access specifiers must be used for main() method?

Correct Answer is : int Read(byte[] buffer ,int offset ,int count)

5. Name the exception thrown by read() on failure.

Correct Answer is : objects of built-in data typed) a reference type

6. Which of these methods are used to read single character from the console?

Correct Answer is : System.Text

7. Which of these method used to read strings from the console?

Correct Answer is : All of the mentioned

8. Which among the following methods are used to write characters to a string?

Correct Answer is : public String(char[ ] value, int startIndex, int length)

9. Which method in Console enables to read individual inputs directly from the keyboard in a non line buffered manner?

Correct Answer is : !=

10. What would be the output for following input from the console as a character? static void Main(string[] args) { Console.WriteLine("what is your name?"); char s; s = Convert.ToChar(Console.ReadLine()); Console.WriteLine("how are you: "+s); Console.Read(); }

Correct Answer is : Hello c Sharp

11. Name the method/methods used to read byte streams from the file?

Correct Answer is : #ERROR!

12. Which of these classes are used by Byte streams for input and output operation?

Correct Answer is : All of the mentioned

13. Which of these method/methods are used to read block or array of bytes from the file?

Correct Answer is : all of the mentioned

14. What is Recursion in CSharp defined as?

Correct Answer is : System.String

15. Which of these will happen if recursive method does not have a base case?

Correct Answer is : Trim()

16. Which of these is not a correct statement?

Correct Answer is : all of the mentioned

17. What will be the correct output for the given code snippet? class recursion { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Program { public static void main(String args[]) { recursion obj = new recursion() ; Console.WriteLine(obj.fact(4)); } }

Correct Answer is : Code runs successfully prints A, B, C, D

18. What will be the correct output the for the given code snippet? class maths { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { static void main(String args[]) { maths obj = new maths() ; Console.WriteLine(obj.fact(1)); } }

Correct Answer is : All of the mentioned

19. What will be the correct output for the given code snippet? class maths { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { static void main(String args[]) { maths obj = new maths() ; Console.WriteLine(obj.fact(4)*obj.fact(2)); } }

Correct Answer is : U T S R Q P O N M L K J I H G F E D C B A

20. What will be the correct output for the given code snippet? class maths { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { static void main(String args[]) { maths obj = new maths() ; Console.WriteLine(obj.fact(4)*(3)); } }

Correct Answer is : U T S R Q P O N M L

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon