AmbitionBox

Discover Best Places to work in India

C# Programming

C# Programming Questions and Answers

Showing 91 - 100 of 174 questions

91

Which of the following statements are correct?

a

String is value type

b

String literals can contain any character literal including escape sequences

c

The equality operators are defined to compare values of string objects as well as references

d

All of the mentioned

correct answer b

Answer: Option (B)

92

Which of these operators can be used to concatenate two or more String objects?

a

+

b

+=

c

&

d

||

correct answer a

string s1 = “Hello”+ ” I ” + “Love” + ” ComputerScience “;
Console.WriteLine(s1);
Hello I Love ComputerScience.

93

The Method use to remove white space from string?

a

Split()

b

Substring()

c

Trim()

d

TrimStart()

correct answer c

Perfectly removes a whitespace from string whereas TrimStart() removes a string of characters from the end of the string.

94

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

a

infinite loop condition occurrence

b

System gets hanged

c

After 10000 executions program will be automatically stopped.

d

None of the mentioned

correct answer a

If a recursive method does not have a base case which is necessary to meet the end of condition then an infinite loop occurs which results in stackoverflow exception error.

95

What is Recursion in CSharp defined as?

a

Recursion is another form of class

b

Recursion is another process of defining a method that calls other methods repeatedly

c

Recursion is a process of defining a method that calls itself repeatedly

d

Recursion is a process of defining a method that calls other methods which in turn calls this method

correct answer c

Recursion is the process of defining something in terms of itself. It allows us to define method that calls itself repeatedly until it meets some base case condition.

96

Which of these is not a correct statement?

a

A recursive method must have a base case

b

Recursion always uses stack

c

Recursion is always managed by C# Runtime environment

d

Recursive methods are faster that programmer written loop to call the function repeatedly using a stack

correct answer c

No matter whatever is the programming language recursion is always managed by operating system.

97

Which of these data types is used by operating system to manage the Recursion in Csharp?

a

Array

b

Queue

c

Tree

d

Stack

correct answer d

Answer: Option (D)

98

Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?

a

getBytes()

b

GetByte()

c

giveByte()

d

Give Bytes()

correct answer a

getBytes() stores the character in an array of bytes. It uses default character to byte conversions.

99

What will be the output of the given code snippet?

staticvoid main(String args[])

{

     char chars[]={'x', 'y', 'z'};

     String s =newString(chars);

     Console.WriteLine(s);

}

 

 

a

x

b

xy

c

z

d

xyz

correct answer d

String(chars) is a constructor of class string, it initializes string s with the values stored in character array chars, therefore s contains “xyz”.
Output :xyz

100

Which of these methods can be used to convert all characters in a String into a character array?

a

CharAt()

b

getChars()

c

TocharArray()

d

All of the mentioned

correct answer c

Answer: Option (C)

Select a company to compare with

vs

Similar Companies