Search Header Logo

3. String manipulation

Authored by Lin Nad

Computers

Professional Development

Used 4+ times

3. String manipulation
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary implication of strings being 'immutable' in C#?

The string will automatically be deleted from memory after its first use.
The string can only contain numeric characters.
The string cannot be changed once it has been created.
The string must be declared using a value type rather than a reference type.

Answer explanation

Immutability means a string value remains unchanged after creation.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In C#, how do you include a double quote character inside a verbatim string literal?

Use two consecutive double quotes ("").
Use the Unicode sequence \u0022.
Use a backslash followed by a quote (\").
Use the @ symbol before the quote.

Answer explanation

Verbatim strings escape embedded quotes by doubling them.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which escape sequence is used to trigger a carriage return in a standard string?

\n
\v
\r
\t

Answer explanation

\r is the standard escape sequence for a carriage return.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the expression " hello ".Trim()?

"hello"
" hello"
"hello "
"h e l l o"

Answer explanation

Trim() removes leading and trailing whitespace from a string.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given text = "Rain, rainbow, brain", what will text.Contains("RAIN", StringComparison.OrdinalIgnoreCase) return?

true
An IndexOutOfRangeException
false
null

Answer explanation

OrdinalIgnoreCase performs a case-insensitive search, so "RAIN" matches "Rain".

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which operator is used to perform a logical exclusive OR (XOR) on boolean operands?

^
||
!
&&

Answer explanation

The ^ operator represents boolean exclusive OR in C#.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

According to the principles of lexical scope, what happens if you attempt to use a variable outside the curly braces in which it was declared?

The variable becomes globally accessible to all classes.
The program will run but use a value of zero for the variable.
The compiler moves the declaration to the top of the file automatically.
A compile-time error occurs because the variable is out of scope.

Answer explanation

A variable can only be used within the scope where it is declared.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?