Computer Programming 1: Fundamentals of Problem Solving, Algorithms, and Java Essentials

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/35

flashcard set

Earn XP

Description and Tags

Comprehensive review flashcards covering problem solving, algorithms, flowcharts, pseudocode, program development cycles, Java data types, identifiers, user input via Scanner, arithmetic, relational, and logical operators.

36 Terms

1
New cards

What is an algorithm?

An algorithm is a sequence of well-defined steps used to solve a problem or accomplish a task.

2
New cards

Why is it important for a programmer to create an algorithm before writing program code?

It acts as a roadmap for the program; without it, the programmer may fail to clearly visualize the instructions and develop a program that does not work as expected.

3
New cards

What are the five characteristics of a good algorithm?

Precision, Uniqueness, Finiteness, Input, and Output.

4
New cards

In algorithm design, what does the characteristic "Finiteness" mean?

It means the algorithm must always stop after a finite number of steps.

5
New cards

What is a flowchart?

A visual representation of an algorithm made up of boxes, diamonds, and other shapes connected by arrows that show the order or link among the steps.

6
New cards

What is the name and purpose of the oval or rounded rectangle shape in a flowchart?

It is called the Terminator symbol (or Start/End symbol) and indicates where the program flow begins and terminates.

7
New cards

In a flowchart, what function does a rectangle represent?

Also called the Action Symbol, it represents a process, an action, or a single calculation/step.

8
New cards

What flowchart shape is used to represent a decision or branching point?

A diamond shape, which poses a question (such as yes/no or true/false) and splits the path into two branches.

9
New cards

What is the parallelogram shape in a flowchart called, and what is its purpose?

It is called the Data symbol (or Input/Output symbol) and is used to input or output data.

10
New cards

What is pseudocode?

A non-formal language intended for human reading that describes computer instructions in a particular order and cannot be executed directly by the computer.

11
New cards

What are the three fundamental structures of flow control?

Sequence, Selection, and Repetition.

12
New cards

How is the "Selection" control structure defined?

It involves decision-making where conditions are evaluated to determine which path or branch of execution the program follows.

13
New cards

How does the "Repetition" control structure function in an algorithm?

It executes and repeats a set of steps continuously until a specified condition is met.

14
New cards

What is the technical definition of a computer?

An electronic device that accepts data as input, processes the data according to instructions, stores information when necessary, and produces output.

15
New cards

What is the primary difference between computer hardware and software?

Hardware refers to the physical components of a computer that can be seen and touched (such as the CPU, RAM, and keyboard), whereas software refers to programs and instructions that tell the hardware what to do.

16
New cards

What are the three core components of the IPO model?

Input (data provided to the program), Process (operations performed on the input), and Output (the information produced after processing).

17
New cards

What are the six sequential stages of the problem-solving process in programming?

  1. Understand the Problem, 2. Analyze the Problem, 3. Develop a Solution, 4. Implement the Solution, 5. Test the Solution, and 6. Improve the Solution.
18
New cards

What are the six phases of the program development cycle?

  1. Problem Definition, 2. Problem Analysis, 3. Program Design, 4. Coding, 5. Testing and Debugging, and 6. Documentation and Maintenance.
19
New cards

What is the difference between a syntax error, a logic error, and a runtime error?

A syntax error violates the language's grammar rules preventing compilation; a logic error allows the program to run but generates incorrect results; and a runtime error occurs during program execution, causing it to crash or fail to complete an operation.

20
New cards

In Java programming, what distinguishes direct variable declaration from indirect declaration?

Direct declaration declares and assigns a variable in a single statement (e.g., int age = 21;), while indirect declaration declares the variable first and assigns its value in a separate later statement (e.g., int sum; followed by sum = 80 + 90;).

21
New cards

What Java class and package are utilized to accept input from a user through the console keyboard?

The Scanner class from the java.util package (imported via import java.util.Scanner;).

22
New cards

Which Scanner method is used to read an entire line of text including spaces versus reading a single word?

nextLine() reads an entire line of text, while next() reads only a single word.

23
New cards

Which Scanner methods are used to read primitive integer, double-precision float, and boolean values?

nextInt() for int, nextDouble() for double, and nextBoolean() for boolean.

24
New cards

What is the purpose of relational operators in Java, and what data type do they evaluate to?

Relational operators are used to compare two values, and they evaluate to a boolean value (true or false).

25
New cards

What are the six relational operators in Java?

== (Equal to), != (Not equal to), > (Greater than), < (Less than), >= (Greater than or equal to), and <= (Less than or equal to).

26
New cards

What are the three logical operators in Java and their functions?

&& (AND, returns true only if both conditions are true), || (OR, returns true if at least one condition is true), and ! (NOT, reverses a boolean value).

27
New cards

What are the eight primitive data types supported in Java?

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

28
New cards

What is the numeric storage range for the Java byte data type?

−128-128 to 127127.

29
New cards

How do float and double data types differ in decimal precision?

float stores 66 to 77 decimal digits, whereas double stores 1515 to 1616 decimal digits.

30
New cards

What is the role of the var keyword in Java variable declarations?

It allows the compiler to automatically detect and assign the appropriate data type based on the initialization value.

31
New cards

What is an identifier in Java?

A name given to programming elements such as variables, classes, methods, packages, and interfaces to uniquely identify them in a program.

32
New cards

What are the naming rules and constraints for Java identifiers?

They can only contain alphanumeric characters ([A-Z], [a-z], [0-9]), $, and _; cannot begin with a digit; are case-sensitive; cannot be reserved words; and have an advisable optimum length of 44 to 1515 letters.

33
New cards

Why are the identifiers "9color", "first-name", and "else" invalid in Java?

"9color" starts with a digit, "first-name" contains an illegal hyphen character (-), and "else" is a Java reserved keyword.

34
New cards

What is string concatenation in Java, and which operator performs it?

It is the process of joining two strings end-to-end to form a single string, performed using the addition operator (+).

35
New cards

What does the Java modulus operator (%) do?

It divides two numbers and returns the remainder of that division.

36
New cards
<p>What will be printed to the console by the Java code shown in the image?</p>

What will be printed to the console by the Java code shown in the image?

1010, 1010, 9090, and 66 (each on a separate line).