chapter 5 Flashcards

1
Q

how do you fetch a set of characters from the keyboad?

A

was how to fetch characters from the computer keyboard. There are lots of ways to do it, but the one I recommend in this chapter is keyboard.nextLine()

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

how does keyboard.nextLine() work?

A

Calling the nextLine method doesn’t just scoop characters from the keyboard. When the computer runs your program, the computer substitutes whatever you type on the keyboard in place of the text keyboard.nextLine().

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

if you want just a word for input do you use keyboard.nextLine() ?

A

But to read a word of input, you don’t call nextWord. (The Java API has no nextWord method.) Instead, to read a word, you call next. keyboard.next()

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

how do you input from the keyboard a number with no decimal point in it?

A

nextInt()

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

how do you input from the keyboard a number with a decimal point in it?

A

nextDouble()

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

how do you input from the keyboard a word (ending in a blank space)

A

next()

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

how do you input from the keyboard a line (or what remains of a line after you’ve already read some data from the line) ?

A

nextLine()

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

how do you input from the keyboard a single character (such as a letter, digit, or punctuation character)

A

findWithinHorizon(“.”,0.charAt(0)

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

```

~~~

what are the 3 main lines that help the computer read input from the keyboard?

A

The three lines are

import java.util.Scanner;

Scanner keyboard = new Scanner(System.in);

keyboard.close();

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

what is the bad news and good news about the reasoning to understand the 3 main lines of code in a Scanner Class?

A

the bad news it’s difficult to understand the reasoning behind the 3 lines

the good news is you dont have to understand the reasoning behind these 3 lines.

just be sure to put these lines in the right places

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

in what order should the 3 main lines in a Scanner class be placed?

A

import java.util.Scanner line the first line in your program.

keyboard = new Scanner(System.in) line inside the main method immediately after the public static void main(String args[]) { line.

keyboard.close() line the last line in your program.

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

should you expect for your code to run the first time you compile your program?

A

It’s unusual for a program to compile and run correctly the first time. There’s almost always a typo or another error of some kind.

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

what’s a good thing to practice before you run your program?

A

Don’t assume that you’ve typed words correctly, that you’ve capitalized words correctly, or that you’ve matched curly braces or parentheses correctly. Compare the code you typed with any sample code that you have. Make sure that every detail is in order.

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

where in the editor does it display a compile time error if your program needs fixing?

A

When Eclipse finds a compile-time error, the editor usually displays at least three red error markers. The marker in the editor’s left margin has an X-like marking and sometimes a tiny light bulb. The marker in the right margin is a small square. The marker in the middle is a jagged red underline.

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

what is the name of the option that allows you to automatically correct an error? how do you activate this option?

A

If you hover the mouse cursor over any of these markers, Eclipse displays a message that attempts to describe the nature of the error. If you hover over the jagged line, Eclipse displays a message and possibly a list of suggested solutions. (Each suggested solution is called a quick fix.) If you right-click the left margin’s marker (or control-click on a Mac) and choose Quick Fix in the resulting context menu, Eclipse displays the suggested solutions. To have Eclipse modify your code automatically (using a suggestion from the quick-fix list), either single-click or double-click the item in the quick-fix list. (That is, single-click anything that looks like a link; double-click anything that doesn’t look like a link.)

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

why use punctuation in Java

A

In English and in Java, using the; proper! punctuation is important)

17
Q

how do you make an abstract method?

A

an advanced feature in which you write a method header without writing a method body. When you do this, you get what’s called an abstract method

18
Q

when is it suggested not to use a quick fix in your code?

A

dont be quick to use a quick fix in your code because if you don’t know what the quickfix actually means then avoid using a quick fix

19
Q
A