CIS 103 Programming Fundamentals I - Chapter 2

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/37

flashcard set

Earn XP

Description and Tags

Flashcards for reviewing Java programming fundamentals, covering topics from program structure and tokens to variables, operators, and type conversions.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

38 Terms

1
New cards

What are the parts of speech in a language like English, which can be compared to elements in a Java program?

Nouns, pronouns, adjectives, verbs, etc.

2
New cards

What is a token in Java?

The smallest unit that composes a Java program.

3
New cards

What are the five types of tokens in Java?

Keywords, Identifiers, Literals/Constants, Special Symbols/Punctuators, Operators

4
New cards

What are keywords or reserved words in Java?

Words reserved for a specific purpose in a programming language.

5
New cards

What are identifiers in Java?

User-defined words used to name classes, variables, and methods.

6
New cards

What are literals or constants in Java?

Values that do not change during the program's execution.

7
New cards

What are special symbols or punctuators in Java?

Characters or symbols used to separate or delineate parts of a program (e.g., [], (), {}, ;, :, =, #).

8
New cards

What are operators in Java?

Symbols that cause the compiler to take specific actions (e.g., +,

9
New cards

What characters can an identifier consist of in Java?

Letters, digits, underscores (_), and dollar signs ($). Must start with a letter, underscore, or dollar sign and cannot be a reserved word.

10
New cards

What is typically known as the standard output device in Java?

The console window that starts a Java application.

11
New cards

What is the standard input device in Java?

The keyboard.

12
New cards

What is used to send information to the standard output device in Java?

A Java class stored in the standard Java library.

13
New cards

What does the println method do in Java?

It places a newline character at the end of whatever is being printed out, moving the cursor to the next line.

14
New cards

How does the print statement differ from the println statement in Java?

It works similarly to println but does not add a newline character at the end of the output.

15
New cards

What is an escape sequence in Java?

A sequence of characters that represents a special character (e.g., \n for newline).

16
New cards

What are some common Java escape sequences and their meanings?

\n (newline), \t (tab), \b (backspace), \r (carriage return), \ (backslash), \' (single quote), \" (double quote).

17
New cards

What operator is used for string concatenation in Java, and what happens if it's used with a string?

The + operator. If either side is a string, the result will be a string.

18
New cards

What are the three characteristics of a space in memory?

Identifier, Data Type, and State.

19
New cards

What does 'variable' mean in programming?

Allocating a space in memory whose state (value) may change.

20
New cards

What does 'constant' mean in programming?

Allocating a space in memory whose state (value) cannot change.

21
New cards

What are the primitive data types in Java?

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

22
New cards

What are the steps for using variables and constants in Java?

Declare, Initialize, Use.

23
New cards

What is the syntax for declaring a variable in Java?

DataType VariableName;

24
New cards

What is the syntax for initializing a variable in Java?

DataType VariableName = Value; or DataType VariableName; VariableName = Value;

25
New cards

What is the syntax for declaring and initializing a constant in Java?

final DataType CONSTANTNAME = Value;

26
New cards

What are the rules for assignment and data types in Java?

Variables can only store values of their own type. Int values can be stored in a Double, but the value is converted to the equivalent real number. Doubles are not compatible with floats due to size/precision.

27
New cards

What does the E or e represent in scientific notation of floating-point literals?

Exponent, and it can be either in lowercase or uppercase.

28
New cards

What are some types of operators in Java?

Arithmetic operators, Augmented assignment operators, Increment/Decrement operators.

29
New cards

What are the arithmetic operators in Java?

  • (Addition), - (Subtraction), * (Multiplication), / (Division), % (Remainder).
30
New cards

How are expressions evaluated when parentheses are used in Java?

The inner most parenthesis are processed first. If two sets of parenthesis are at the same level, they are processed left to right.

31
New cards

What happens in integer division in Java?

It truncates any decimal remainder. For example, 5 / 2 yields 2.

32
New cards

What class needs to be imported to allow a program to read data values?

import java.util.Scanner;

33
New cards

What are the phases of the software development process?

Requirement Specification, System Analysis, System Design, Implementation, Testing, Deployment, Maintenance.

34
New cards

List some common errors and pitfalls in Java programming.

Undeclared/Uninitialized Variables and Unused Variables, Integer Overflow, Round-off Errors, Unintended Integer Division, Redundant Input Objects.

35
New cards

What is the result of an even number % 2

Always 0 and an odd number % 2 is always 1.

36
New cards

What code is missing in Line 2: Missing static for the main method.

public static void main(String[] args)

37
New cards

How do you write a statement to let the user enter a double value from the keyboard?

Use Scanner input = new Scanner(System.in); double value = input.nextDouble();

38
New cards

What happens if you entered 5a when executing the following code: double radius = input.nextDouble();

A runtime error will occur if you entered 5a when executing the following code: