Module 2

studied byStudied by 0 people
0.0(0)
Get a hint
Hint

What is a string literal in Java?

1 / 20

flashcard set

Earn XP

Description and Tags

Intro to Java

21 Terms

1

What is a string literal in Java?

A string of characters represented by enclosing it in double quotes.

New cards
2

What method is used to print a character string to the console in Java?

The println method.

New cards
3

How does the print method differ from the println method?

The print method does not advance to the next line after printing.

New cards
4

What operator is used for string concatenation in Java?

The + operator.

New cards
5

What are some examples of Java escape sequences?

\b (backspace), \t (tab), \n (newline), " (double quote).

New cards
6

What is a variable in Java?

A name for a location in memory that can hold a value.

New cards
7

What does the assignment operator do in Java?

It changes the value of a variable.

New cards
8

What keyword is used to declare a constant in Java?

The final modifier.

New cards
9

What are the eight primitive data types in Java?

byte, short, int, long, float, double, char, boolean.

New cards
10

What is the difference between widening and narrowing conversions?

Widening conversions go from a smaller to a larger data type, while narrowing conversions go from a larger to a smaller type and can lose information.

New cards
11

What class in Java is used for reading user input?

The Scanner class.

New cards
12

What does the nextLine method of the Scanner class do?

It reads all input until the end of the line as a character string.

New cards
13

What is the purpose of the conversion operators in Java?

To convert data from one type to another.

New cards
14

How are arithmetic expressions evaluated in terms of operator precedence?

Multiplication, division, and remainder are evaluated before addition and subtraction.

New cards
15

What happens if you use the / operator with two integers in Java?

The result will be an integer with the fractional part discarded.

New cards
16

How can you avoid ambiguity in operator precedence in an expression?

By using parentheses to explicitly define the order of evaluation.

New cards
17

What is the result of using the increment operator on a variable?

It adds one to the variable's current value.

New cards
18

What is the significance of a boolean value in Java?

It represents a true or false condition.

New cards
19

What does the Scanner class require to be imported to use it in a program?

The java.util class library.

New cards
20

How does the initialization of a variable work in Java?

A variable can be given an initial value at the time of declaration.

New cards
21

When is the result of an expression in Java evaluated?

The expression on the right side of an assignment operator is evaluated before storing the result in the variable on the left.

New cards

Explore top notes

note Note
studied byStudied by 18 people
... ago
5.0(1)
note Note
studied byStudied by 36 people
... ago
5.0(1)
note Note
studied byStudied by 9 people
... ago
5.0(1)
note Note
studied byStudied by 22 people
... ago
5.0(1)
note Note
studied byStudied by 6 people
... ago
5.0(1)
note Note
studied byStudied by 5 people
... ago
5.0(1)
note Note
studied byStudied by 12 people
... ago
5.0(1)
note Note
studied byStudied by 91 people
... ago
5.0(2)

Explore top flashcards

flashcards Flashcard (54)
studied byStudied by 33 people
... ago
5.0(1)
flashcards Flashcard (166)
studied byStudied by 76 people
... ago
5.0(2)
flashcards Flashcard (30)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 5 people
... ago
5.0(1)
flashcards Flashcard (135)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (71)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (303)
studied byStudied by 15 people
... ago
5.0(1)
flashcards Flashcard (26)
studied byStudied by 20 people
... ago
5.0(2)
robot