Syntax Flashcards

1
Q

How do you import the scanner class?

A

import java.util.Scanner;

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

How do you create a new scanner class?

A

Scanner input = new Scanner(system.in);

Where input is the name of the class.

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

How do you use the scanner class you created?

A

int length;
length = input.nextInt();

Where input is the name of the scanner class.

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

How to let the user input a string?

A

String hello;
hello = input.nextLine();

Where input is the name of the scanner class.

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

How do you make the Scanner class read a character?

A

char initial;
initial = input.nextLine().charAt(0);

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

This statement is used to indicate that the case statement is finished.

A

break

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