wallwalker: Venetian mask, dark purple with gold gilding. (Default)
Keeping track of some of the interview questions I've seen/been told about, for reference.

When to use certain data types.

1. String
The big advantage of strings over other datatypes for me is their immutability; if you want something that isn't going to change, a string is good. I also forgot to mention the advantage of indexing, but that's something you can also get with a char array, and they work more quickly (at least in Java. In C++, a string IS a char array.)
An answer to look at later: Advantages and Disadvantages of String in Java on Spec-India.

2. Integer
Part of my answer was for precise calculations, since floating point numbers weren't as precise. (This came partially from my Algorithms professor. He suggested converting decimals to integers whenever possible, such as when using dollars, because the calculations were easier for the programming language to deal with and because floating points could not be calculated with as much precision.) But they are basically useful whenever you can split values into discrete equal parts and work with them piece by piece.

3. Enum
I'm just not as good with these, to be honest. The only example I could come up with when I could use them was from an online course that I took. But from what I understand, they're really useful to prevent the need for error-checking, because you already have the allowed responses in the enum definition.

Profile

wallwalker: Venetian mask, dark purple with gold gilding. (Default)
wallwalker

November 2024

S M T W T F S
      12
3456789
10111213141516
17181920212223
24252627282930

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 16th, 2025 11:28 pm
Powered by Dreamwidth Studios