chapter 8 Flashcards

1
Q

what type of variable is used to store a single character?

A

The Java type that’s used to store characters is char.

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

when you write a char type variable, what symbol surrounds the character?

A

In a Java program, every char literal starts and ends with a single quote mark.

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

why do you need to surround a char type variable with single a sing quote mark on each side?

A

When you surround a letter with quote marks, you tell the computer that the letter isn’t a variable name.

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

what are you telling the computer when you surround a letter with quote marks?

A

When you surround a letter with quote marks, you tell the computer that the letter isn’t a variable name.

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

what does the method whose name is Character.toUpperCase do?

A

the program calls an API method whose name is Character.toUpperCase. The method Character.toUpperCase does what it’s name suggests– the method produces the uppercase equivalent of a lowercase letter

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

what happens when you hand a program a capital letter and use the toUpperCase method?

A

nothing happens. you are returned a capital letter as before if you print it to the screen.

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

what happens if you feed the to UpperCase method a digit like 3?

A

nothing happens but if you print it out you recieve the same number 3.

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

when you are writing if there is something you don’t quite understand what should you do?

A

when you don’t understand something about computer programming, it often helps to write a test program. Make up an experiment and see how the computer responds.

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

why is it not a good idea to rely solely on the api document for answers?

A

because whatever the API answers, it ignores three other questions so be bold and don’t be afraid to tinker

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

what happens if you store more than 1 character in a char variable?

A

You can’t store more than one letter at a time in a char variable, and you can’t put more than one letter between a pair of single quotes.

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

what kind of variable do you need if you wanted to store more than 1 character in a variable?

A

If you’re trying to store words or sentences not just single letters, then you need to use something called a String.

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

when is the best time not to reuse a variable in your program?

A

in smaller program’s you do not need to reuse variables.

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

when is the best time to reuse a variable in your program?

A

in larger programs it’s better to reuse a variable because instead of hardcoding the variable again, you can simply summon an older version of that

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

how do you know when or when not to reuse variables?

A

it all depends on what you’re trying to do. the best way to know when or when not to reuse variables is by much practice.

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

g

what is it that the findWithinHorizon(“.”,0) method is looking for in the input?

A

using the findWithinHorizon(“.”,0) method looks for things in the input and depending on the stuff you put in parentheses.

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

what does \d in special code called and what does it stand for?

A

in special code it’s called a regular expression. it stands for a single digit.

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

when it comes to regular expressions, what does a dot mean?

A

a dot stands for any character at all.

18
Q

when using the findWithinHorizon(“.”,0) method, what does the 0 stand for?

A

the 0 means for the method to keep seaching until the end of the input.

19
Q

what does the paired combination of (“.”,0) tell the findWithinHorizon method?

A

it says to keep searching until any character that the user types on the keyboard.

20
Q

why does the findWithinHorizon method, include the name Horizon for this method name?

A

because it searches as far as the method sees until it finds what is within the parentheses.

21
Q

if your input for a findWithinHorizon (“\d\d\d”, 9) method is “Testing 1” or “Testing 123” doesn’t work then what needs number does the number 9 need to be altered to so that it won’t return null? and why? and if you printed the method input what would display if it worked?

A

you would need 3 consecutive digits not letters but the letters will only count as a number as well as spaces so you would have to change the 9 to 11 and it will not work with only one consecutive digit

22
Q

What’s the role of charAt(0) in reading a single character?

A

it takes care of the multicharacter problem as it tells Java to pick the initial character from any of the characters that findWithinHorizon fetches.

23
Q

how does writing input for two findWithinHorizon(“.”, 0) methods for 2 letters differ from inputing 2 numbers ?

A

when it comes to letters you don’t need to write a space but when it comes to numbers, you do need to space each number when you enter 2 or more amounts.

24
Q

what happens when you call 2 findWithinHorizon(“.”, 0) methods and your input is “p o”, with a space between the “p” and the “o”?

A

the program will count the space as a character in your input

25
Q

what if your program calls a nextInt followed by a findWithinHorizon(“.”, 0) method? how would you type the input if your nextInt was 80 and your character an “x”? and why?

A

when you type letters and numbers into the input, make sure you write a space between the number and the letter. example “80 x” and make sure you add another findWithinHorizon method in between to make up for the blank space in your input.

26
Q

what do you need in a program for a question that the answer is either a yes or a no?

A

you need a variable of type boolean because it stores one of two values – true or false

27
Q

how do you compare boolean value to another variable?

A

by using a comparison operator

28
Q

what are the types of comparison operators?

A

== is equal to
!= is not equal to
< is less than
> is greater than
> <= is less than or equal to
> >= is greater than or equal to

29
Q

what is a debugger and what is it used for?

A

a debugger automatically adds invisible print and println calls to your suspicious code. In fact, debuggers have all kinds of features to help you diagnose problems.

30
Q

what is the debug perspective?

A

a debug perspective helps you diagnose errors in your code.

31
Q

when is debugging an essential tool?

A

in any large programming project, automated debugging is an essential tool.

32
Q

what is special during the middle of a run when using a debugger?

A

using the debugging tools, can examine variables’ values in the middle of a run!

33
Q

when it comes to letters of the alphabet both lower case and upper case, what is the order of both alphabets

A

capital D is lower than lowercase a. first capitals then lowercase letters come next in order.

34
Q

when it comes to capitals, what is the order of numeric codes since the alphabet starts with uppercase letters?

A

Capital A’s numeric code is 65 and Capital Z’s numeric code is 90

35
Q

when it comes to lower case letters, what is the order of numeric codes for lowercase letters?

A

lowercase a is 97 and lowercase z is 122

36
Q

how many types of primitive variables are there?

A

there are 6 primitive numeric types and 2 primitive other types such as char and boolean

37
Q

what are the range of values for a char type variable?

A

thousands of characters, glyphs, and symbols

38
Q

what are the range of values for a boolean type of variable?

A

only true or false

39
Q

why do they consider a char type a numeric type?

A

because char can hold something called unicode – an international standard for representing alphabets of the world’s many languages.

40
Q

what is a glyph? and what is an allograph?

A

a glyph is a particular representation of a character. comparing two glyphs that look different but have the same representation of the same character makes them allographs