C# Interview Questions - 25 | Snaprecruit.com

C# Interview Questions - 25 | Snaprecruit.com

C SHARP interview questions part 25

C SHARP interview questions part 25

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

Total Questions: 20

1. Which among the following is the correct way to find out the index of second ‘s’ in the string “She sold her beauty in one night to someone else”?

Correct Answer is : public int cube(int x)

2. What is the String in C# meant for?

Correct Answer is : Compile time error

3. What does the term ‘immutable’ means in term of string objects?

Correct Answer is : both process & thread based

4. To perform comparison operation on strings supported operations are :

Correct Answer is : Both A feature that allows our computer to run two or more programs concurrently & A program that acts as a small unit of code that can be dispatched by the scheduler

5. What will be output of the following set of code : static void Main(string[] args) { string s1 = "Hello I Love Csharp "; Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.IndexOf('p')); Console.ReadLine(); }

Correct Answer is : Only Enables to utilize the idle time present in most programs

6. Correct way to convert a string to uppercase using string class method()?

Correct Answer is : both foreground & background

7. What would be the output for the following set of code? static void Main(string[] args) { String obj = "hello"; String obj1 = "world"; String obj2 = obj; Console.WriteLine (obj.Equals(obj2) + " " + obj2.CompareTo(obj) ); Console.ReadLine(); }

Correct Answer is : System.Threading

8. What would be the output for the code below? static void Main(string[] args) { String obj = "hello"; String obj1 = "world"; String obj2 = obj; Console.WriteLine(obj + " " + obj1); string s = obj + " " + obj1; Console.WriteLine(s.Length); Console.ReadLine(); }

Correct Answer is : Only Defines a thread & Declaration of a thread constructor

9. What is output for the following set of Code? static void Main(string[] args) { String obj = "hello"; String obj1 = "world"; String obj2 = obj; string s = obj+" "+obj1; Console.WriteLine(s.IndexOf('r')); Console.ReadLine(); }

Correct Answer is : Thread

10. What is output for the set of code? static void Main(string[] args) { String obj = "hello"; String obj1 = "world"; String obj2 = obj; string s = obj + " " + obj1; Console.WriteLine(s.Substring(6 ,5)); Console.ReadLine(); }

Correct Answer is : Start()

11. What will be the output for the set of given code? static void Main(string[] args) { String obj = "hello"; String obj1 = "worn"; String obj2 = obj; Console.WriteLine(obj + " " + (obj1.Replace('w' ,'c'))); Console.ReadLine(); }

Correct Answer is : sleep()

12. What will be the output of the given code snippet? static void Main(string[] args) { string s1 = "olleH"; string s2 = "olleh"; if (s1 == s2) Console.WriteLine("Equal"); else Console.WriteLine("Unequal"); if (s1.Equals(s2)) Console.WriteLine("Equal"); else Console.WriteLine("Unequal"); Console.ReadLine(); }

Correct Answer is : synchronized

13. What will be the output of the given code snippet? static void Main(string[] args){ string s1 = " Ixg"; string s2 = s1.Insert(3,"i"); string s3 = s2.Insert(5, "o"); for (int i = 0; i < s3.Length; i++) Console.WriteLine(s3[i]); Console.ReadLine();}

Correct Answer is : lock

14. What will be the output of the given code snippet? class Program { static void Main(string[] args) { char []chars = {'a', 'b', 'c'}; String s = new String(chars); Console.WriteLine(s); Console.ReadLine(); } }

Correct Answer is : It’s a process of handling situations when two or more threads need access to a shared resource

15. What will be the output of given code snippet? class Program { static void Main(string[] args) { char []chars = {'a', 'b', 'c'}; String s = new String(chars); String s1 = "abcd"; int len1 = s1.Length; int len2 = s.Length; Console.WriteLine(len1 + " " + len2); Console.ReadLine(); } }

Correct Answer is : Wait()

16. What will be the output of given code snippet? class A { int i; int j; public A() { i = 1; j = 2; } } class Program { static void Main(string[] args) { A obj1 = new A(); Console.WriteLine(obj1.ToString()); Console.ReadLine(); } }

Correct Answer is : SynchronizationLockException

17. Which of these constructors is used to create an empty String object?

Correct Answer is : a mutually exclusive synchronization object

18. Which of these method of class String is used to obtain length of String object?

Correct Answer is : All of the mentioned

19. What will be the output of the given code snippet? class Program { static void Main(string[] args) { String c = "Hello i love Csharp"; Boolean var; var = c.StartsWith("hello"); Console.WriteLine(var); Console.ReadLine(); } }

Correct Answer is : Abort()

20. What is the value returned by the function CompareTo() if the invoking string is less than the string compared?

Correct Answer is : A thread can exist only in two states, running and blocked

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon