Glossary
Arithmetic operators
Symbols used to perform mathematical calculations, such as addition (+), subtraction (-), multiplication (*), division (/), and modulo (%).
Example:
The expression result = 10 * 5 + 2; uses arithmetic operators for multiplication and addition.
Assignment operator (=)
The operator used to assign a value to a variable.
Example:
In int score = 100;, the assignment operator = gives the score variable the value 100.
Binary
The fundamental language computers understand, consisting solely of 0s and 1s.
Example:
When you type a letter on your keyboard, the computer converts it into binary code for processing.
Casting
The process of explicitly converting a value from one data type to another.
Example:
int result = (int) 5.7; uses casting to convert the double 5.7 into the integer 5.
Class
A blueprint or template for creating objects, defining their properties (attributes) and behaviors (methods).
Example:
In Java, public *class* Main defines the structure for your program's entry point.
Compiler
A program that translates source code written in a high-level language (like Java) into machine code (binary) that a computer can execute.
Example:
Before running your Java program, the compiler checks for syntax errors and converts it into bytecode.
Compound assignment operators
Shorthand operators that combine an arithmetic operation with an assignment, such as `+=`, `-=`, `*=`, `/=`, and `%=`.
Example:
total += 5; is a compound assignment operator that adds 5 to total and assigns the new value back to total.
Constant (using final)
A variable whose value, once assigned, cannot be changed throughout the program's execution, declared using the `final` keyword.
Example:
final double PI = 3.14159; declares PI as a constant that will always hold the value 3.14159.
Declaration (of variable)
The process of defining a variable's name and its data type before it can be used in a program.
Example:
int age; is a declaration that tells Java you'll be using an integer variable named age.
Decrement operator (--)
A unary operator that decreases the value of a variable by 1.
Example:
lives--; is equivalent to lives = lives - 1; and uses the decrement operator.
Double division
Division where at least one of the operands is a double (or float), resulting in a floating-point number with decimal precision.
Example:
10.0 / 3 results in 3.333... because it performs double division.
High-level language
A type of programming language that is more human-readable and abstract, making it easier to write and understand code.
Example:
Java, Python, and Kotlin are examples of high-level languages that abstract away complex machine details.
Increment operator (++)
A unary operator that increases the value of a variable by 1.
Example:
count++; is equivalent to count = count + 1; and uses the increment operator.
Initialization (of variable)
The process of assigning an initial value to a variable when it is declared or at a later point.
Example:
age = 15; is the initialization of the age variable, giving it a starting value.
InputMismatchException
A runtime error that occurs when the input provided by the user does not match the expected data type for a `Scanner` method.
Example:
If you use input.nextInt() but the user types 'hello', it will cause an InputMismatchException.
Integer division
Division performed between two integers, where the result is also an integer with any decimal part truncated (cut off).
Example:
10 / 3 results in 3 due to integer division, discarding the .333 part.
Low-level language
A type of programming language that is very close to machine code and difficult for humans to read and write directly.
Example:
Assembly language is a low-level language often used for direct hardware manipulation in specialized systems.
Main method
The specific method in a Java program where the program execution begins.
Example:
The public static void *main method*(String[] args) is the starting point for any executable Java application.
Primitive data types
Basic data types in Java that store data directly in memory, such as integers, floating-point numbers, and boolean values.
Example:
int, double, and boolean are examples of primitive data types in Java.
Programming
The art of giving computers instructions to perform tasks, creating the software that powers our world.
Example:
Building a mobile app that tracks your fitness goals involves extensive programming.
Programming Language
A formal language designed to communicate instructions to a machine, bridging the gap between human-readable code and binary.
Example:
Java is a popular programming language widely used for developing various software applications.
Reserved words
Keywords in Java that have a predefined meaning and cannot be used as identifiers (like variable names or class names).
Example:
You cannot name a variable public or int because they are reserved words in Java.
Scanner class
A utility class in Java used to obtain input from the user, typically from the console.
Example:
To read user input, you first need to create an object of the *Scanner class*: Scanner input = new Scanner(System.in);.
String literal
A sequence of characters enclosed in double quotes, representing a fixed string value directly in the code.
Example:
In System.out.println("Hello world!");, "Hello world!" is a string literal.
System.out.print()
A Java statement used to print output to the console without adding a new line, allowing subsequent output to appear on the same line.
Example:
If you want 'Hello' and 'World' to appear on the same line, you'd use *System.out.print*("Hello "); System.out.print("World!");.
System.out.println()
A Java statement used to print output to the console, automatically adding a new line after the printed content.
Example:
To display 'Game Over!' on a new line, you would use *System.out.println*("Game Over!");.
Variable Ranges
The minimum and maximum values that a specific data type can store due to the finite memory allocated for it.
Example:
An int variable has a defined variable range from Integer.MIN_VALUE to Integer.MAX_VALUE.
Variables
Named storage locations in a computer's memory used to hold a value that can change during program execution.
Example:
int score = 100; declares an int variable named score and assigns it the value 100.
boolean
A primitive data type in Java that can only hold one of two values: `true` or `false`.
Example:
A *boolean* variable named isLoggedIn could be true if a user is logged in, or false otherwise.
double
A primitive data type in Java used to store floating-point numbers (decimal numbers) with double precision.
Example:
To represent a price like 19.99 or a temperature like 98.6, you would use a *double*.
input.nextBoolean()
A method of the `Scanner` class used to read the next token of input as a boolean value (`true` or `false`).
Example:
To ask if a user is a student, you might use boolean isStudent = *input.nextBoolean*();.
input.nextDouble()
A method of the `Scanner` class used to read the next token of input as a double-precision floating-point number.
Example:
To read a user's height with decimals, you would use double height = *input.nextDouble*();.
input.nextInt()
A method of the `Scanner` class used to read the next token of input as an integer.
Example:
To read a user's age, you would use int age = *input.nextInt*();.
input.nextLine()
A method of the `Scanner` class used to read an entire line of text input from the user, including spaces, until a new line character is encountered.
Example:
To get a user's full name, you would use String fullName = *input.nextLine*();.
int
A primitive data type in Java used to store whole numbers (integers) without any decimal part.
Example:
You would use an *int* to store a student's score or the number_of_apples.