{ "@context": "https://schema.org", "@type": "Organization", "name": "Brainscape", "url": "https://www.brainscape.com/", "logo": "https://www.brainscape.com/pks/images/cms/public-views/shared/Brainscape-logo-c4e172b280b4616f7fda.svg", "sameAs": [ "https://www.facebook.com/Brainscape", "https://x.com/brainscape", "https://www.linkedin.com/company/brainscape", "https://www.instagram.com/brainscape/", "https://www.tiktok.com/@brainscapeu", "https://www.pinterest.com/brainscape/", "https://www.youtube.com/@BrainscapeNY" ], "contactPoint": { "@type": "ContactPoint", "telephone": "(929) 334-4005", "contactType": "customer service", "availableLanguage": ["English"] }, "founder": { "@type": "Person", "name": "Andrew Cohen" }, "description": "Brainscape’s spaced repetition system is proven to DOUBLE learning results! Find, make, and study flashcards online or in our mobile app. Serious learners only.", "address": { "@type": "PostalAddress", "streetAddress": "159 W 25th St, Ste 517", "addressLocality": "New York", "addressRegion": "NY", "postalCode": "10001", "addressCountry": "USA" } }

Learning Unit 8 Programming Theory Flashcards

(10 cards)

1
Q

String Classes

A
  • To Uppercase();
  • To Lowercase();
  • charAt();
  • Substring();
  • Equals ();
  • Equals IgnoreCase();
  • Compare To();
  • Compare to IgnoreCase();
  • Length();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Equals and equals IgnoreCase Methods:

A
  • Instead of operators: methods of string class are used to compare strings.
  • Equals method takes the second string as a parameter
  • Equals IgnoreCase is useful when: you don’t want to worry about the case the user has entered the data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

toLowerCase and toUpperCase Methods:

A

Changes all the characters in the string to either uppercase or lowercase.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How Strings are compared:

A
  • Computer looks at each character individually .
  • Computer compares Unicode values (numbers).
  • If the words are not the same length, it will add the necessary spaces on the end of the shorter word before comparing words.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Alphabetic Order using the compare to method:

A
  • +ve result: 2nd value is alphabetically first
  • -ve result: 1st value is alphabetically first
  • Computer checks Unicode value of each characters in each word, the subtracts values to determine if the difference in values is -ve/+ve.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How a switch statement works/When a switch statement executes:

A
  1. Interpreter computes the value of expression in brackets after the word switch.
  2. Looks for a case label that matches value.
  3. If it finds a match: interpreter starts executing block of code at 1st statement of case label.
  4. If it doesn’t find a match: interpreter starts execution at 1st statement following default.
  5. If no default: interpreter skips body of switch block and carries on with the rest of the program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Investigation of the break statements:

A
  • The absence of the break statements: statement begins executing code at 1st statement after matching case label and continues executing statements until it reaches the end of the switch block.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Important Points on the Switch Statement/Case Statement

A
  • If one value has the same output: each value must have case in front of it and a colon after.
  • Break causes switch statement to be exited.
  • No default and none of case labels match input value: program will jump to the line after the end of switch statement and continue.
  • Relational operators may not be used: case labels and switch statements only check constant values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why is the ‘shortened’ version of declaring a String allowed?

A

Strings are commonly used, it makes it easier to declare them like the other data types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Use of a break keyword

A

Each case clause causes interpreter to exit switch statement when it has executed the statements in that case. End of case must be specified using a break statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly