ExamVeda
Login
Home
41
What is the correct way to declare and initialize a jagged array with 2 rows in C#?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
42
What is the correct syntax to access the second character of a string named text in C#?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
43
What is the result of the expression Array.IndexOf(numbers, 5) where numbers = {1, 2, 3, 4, 5} in C#?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
44
In C#, which method is used to split a string into substrings based on a specified delimiter?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
45
What is the correct way to declare and initialize a multidimensional array with 3 rows and 4 columns in C#?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
46
Which of these methods of class String is used to extract all the characters from a String object?
Discuss
Answer & Solution
Answer: Option E
Solution:
The question asks which method of the String class in C# is used to extract all characters from a string.

The correct method is ToCharArray(), which converts the entire string into an array of characters.

Syntax:
char[] ToCharArray()

This method returns a character array containing all the characters of the string in the same sequence.

Example:
string myString = "Hello";
char[] chars = myString.ToCharArray();
After execution, chars will contain: ['H', 'e', 'l', 'l', 'o'].

Option A: CHARAT() – Invalid in C#. It belongs to Java and has incorrect casing.

Option B: Remove() – Used to delete a portion of a string, not to extract characters.

Option C: charAt() – Also a Java method, not part of C#.

Option D: Replace() – Used to replace characters or substrings, not to extract them.

Therefore, the correct and updated answer is Option E: ToCharArray().
47
What will be the output of the following C# 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();
    }
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
48
Which of these base classes are accessible to the derived class members?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
49
What is the process by which we can control parts of a program that can access the members of a class?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
50
Which of these methods of class are used to remove the leading and backward whitespaces?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board