E-learning that I don't agree with

T

Tony Johansson

Hi!

We have this question
Match the following features with the correct options. The correct answer is
3A
1B
2C
4D

1. Improves performance with strings to make .NET Framework applications
efficient.
2. Does not let you change the value of a string after it is assigned to an
object.
3. Helps you handle strings efficiently.
4. Converts the string value contained in the StringBuilder class to a
string

A. StringBuilder class.
B. String interning.
C. Immutable strings.
D. ToString method.

I do agree with 2C and 4D but the other two is difficult.
I mean a StringBuilder match both 1 and 3 and so does
string interning

Can somebody tell me why number 3 match A and not B and
why 1 match B and not A

//Tony
 
G

Gregory A. Beamer

Tony Johansson said:
Hi!

We have this question
Match the following features with the correct options. The correct answer
is
3A
1B

1. Improves performance with strings to make .NET Framework applications
efficient.
3. Helps you handle strings efficiently.

A. StringBuilder class.
B. String interning.

I do agree with 2C and 4D but the other two is difficult.
I mean a StringBuilder match both 1 and 3 and so does
string interning

Can somebody tell me why number 3 match A and not B and
why 1 match B and not A

A StringBuilder does not actually help "handle strings" in an efficient
manner, it helps you build a character array that can easily be turned into
a string to avoid the immutable-ness of strings. Certainly, this means
efficiency in adding to a string, as you do not create a new object with
each addition, but you are not really handling the string itself, but rather
getting a string out of the character array when you need it.

I would not say that string.Intern() actually makes handling strings more
efficient, as that is an awfully broad statement (typical of these types of
questions), but it does help efficiently compare strings, along with a few
other tasks, so it is the best choice out of the mix, if you have to have
only one choice per item.

I hope that helps. And, yes, it is pulling wings off a gnat to an extent.
:)

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
F

Family Tree Mike

Hi!

We have this question
Match the following features with the correct options. The correct answer is
3A
1B
2C
4D

1. Improves performance with strings to make .NET Framework applications
efficient.
2. Does not let you change the value of a string after it is assigned to an
object.
3. Helps you handle strings efficiently.
4. Converts the string value contained in the StringBuilder class to a
string

A. StringBuilder class.
B. String interning.
C. Immutable strings.
D. ToString method.

I do agree with 2C and 4D but the other two is difficult.
I mean a StringBuilder match both 1 and 3 and so does
string interning

Can somebody tell me why number 3 match A and not B and
why 1 match B and not A

//Tony

I believe that 3 "best matches" A, since it says, "helps _you_ handle
strings efficiently.". String Interning, to the best of my knowledge,
is not directly accessable to _you_ though it helps .Net Framework
applications be efficient. This makes 3-A and 1-B be the best choices,
in my opinion.
 
W

Willem van Rumpt

Tony said:
Hi!

We have this question
Match the following features with the correct options. The correct answer is
3A
1B
2C
4D

1. Improves performance with strings to make .NET Framework applications
efficient.
2. Does not let you change the value of a string after it is assigned to an
object.
3. Helps you handle strings efficiently.
4. Converts the string value contained in the StringBuilder class to a
string

A. StringBuilder class.
B. String interning.
C. Immutable strings.
D. ToString method.

I do agree with 2C and 4D but the other two is difficult.
I mean a StringBuilder match both 1 and 3 and so does
string interning

Can somebody tell me why number 3 match A and not B and
why 1 match B and not A

//Tony

Because option 1 happens regardsless, without you doing anything.

The *.NET Framework* handles string interning, without your
intervention, to improve performance. There are options for you to
specify that a string should be interned. But (AFAIK), there's no way to
specify that a string should *not* be interned.

OTOH, only *you* can decide to use a StringBuilder, to improve performance.
 
T

Tony Johansson

Willem van Rumpt said:
Because option 1 happens regardsless, without you doing anything.

The *.NET Framework* handles string interning, without your intervention,
to improve performance. There are options for you to specify that a string
should be interned. But (AFAIK), there's no way to specify that a string
should *not* be interned.

OTOH, only *you* can decide to use a StringBuilder, to improve
performance.

Good explained !!
 
A

Arne Vajhøj

We have this question
Match the following features with the correct options. The correct answer is
3A
1B
2C
4D

1. Improves performance with strings to make .NET Framework applications
efficient.

A or C.
2. Does not let you change the value of a string after it is assigned to an
object.

Obviously C.
3. Helps you handle strings efficiently.

A or C.
4. Converts the string value contained in the StringBuilder class to a
string

Obviously D.
A. StringBuilder class.
B. String interning.
C. Immutable strings.
D. ToString method.

I do agree with 2C and 4D but the other two is difficult.
I mean a StringBuilder match both 1 and 3 and so does
string interning

Can somebody tell me why number 3 match A and not B and
why 1 match B and not A

No.

It is not particular logical to expect a large performance
gain from String interning.

Arne
 
A

Arne Vajhøj

A StringBuilder does not actually help "handle strings" in an efficient
manner, it helps you build a character array that can easily be turned
into a string to avoid the immutable-ness of strings. Certainly, this
means efficiency in adding to a string, as you do not create a new
object with each addition, but you are not really handling the string
itself, but rather getting a string out of the character array when you
need it.

Depends on what is "handle strings". Strings are very frequent
arguments to StringBuilder methods (Append).

Arne
 
P

Peter Duniho

Arne said:
Depends on what is "handle strings". Strings are very frequent
arguments to StringBuilder methods (Append).

And a StringBuilder can itself be thought of as a mutable string.

The question Tony's asking about is very badly written, with ambiguously
similar phrases. I stand by my previous recommendation to just stop
using this training material. But I would say that there's a plausible
argument in favor of the given answers, however vaguely written.

Pete
 
G

Gregory A. Beamer

Arne Vajhøj said:
Depends on what is "handle strings". Strings are very frequent
arguments to StringBuilder methods (Append).

If strings are arguments, they are broken down into character arrays and
added into the larger array. As such, I do not see it as "handling" the
string. The main purpose of a StringBuilder is to get around the immutable
nature of strings. Rather than concat and create numerous objects, you
continue to add to a character array until you are ready to spit it out as a
string.

Overall, I agree with Tony that it is a bad question, but most of the
multiple guess and match questions on tests are pretty bad, unless they get
very specific. I am not fond of the Microsoft trivia questions for
interviews or certification. They are necessary evils, I guess.

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
G

Gregory A. Beamer

Family Tree Mike said:
String Interning, to the best of my knowledge, is not directly accessable
to _you_ though it helps .Net Framework applications be efficient.

Intern() is a static method that is public, so it is available. I have not
had used string interning myself, as I don't have a need (yet?) for multiple
string references to a single string object.

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
A

Arne Vajhøj

If strings are arguments, they are broken down into character arrays and
added into the larger array. As such, I do not see it as "handling" the
string.

It is handling the string's that is being passed to it.

The rest is implementation.
The main purpose of a StringBuilder is to get around the
immutable nature of strings. Rather than concat and create numerous
objects, you continue to add to a character array until you are ready to
spit it out as a string.

I don't think anyone is arguing against that.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top