Video Notes on Java Basics: Variables, Types, Literals, Expressions, Subroutines, and Objects

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

1/55

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering identifiers, literals, types, variables, operators, subroutines, objects, arrays, and basic Java concepts from the video notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

56 Terms

1
New cards

Identifier

A valid Java name that can refer to classes, variables, or subroutines; must start with a letter or underscore and contain only letters, digits, and underscores; is case sensitive and cannot be a reserved word.

2
New cards

Reserved words

Java keywords like class, public, static, if, else, while; they cannot be used as identifiers.

3
New cards

camelCase

Naming convention where multi-word identifiers start with a lowercase letter and each subsequent word begins with an uppercase letter.

4
New cards

camelCase vs underscores

Camel case is preferred for class names (UpperCamelCase) and variables/methods for lowerCamelCase; underscores are less common in Java identifiers.

5
New cards

Compound name

A name that contains multiple simple names separated by periods, e.g., System.out.println, indicating containment and hierarchy.

6
New cards

Variable

A memory reference (a box) used to store data; a variable refers to the box and indirectly to the data inside it.

7
New cards

Assignment statement

A command of the form variable = expression that stores the value of the expression into the variable; executes at a specific time during program run.

8
New cards

Primitive types

Eight built-in types in Java: byte, short, int, long, float, double, char, and boolean.

9
New cards

byte

8-bit integer type with range -128 to 127; stores a single byte of memory.

10
New cards

short

16-bit integer type; range -32768 to 32767.

11
New cards

int

32-bit integer type; commonly used for integers in Java.

12
New cards

long

64-bit integer type; large range for integers.

13
New cards

float

32-bit floating-point type; used for real numbers with about 7 digits of precision.

14
New cards

double

64-bit floating-point type; more precision than float; standard for real numbers.

15
New cards

char

16-bit Unicode character type; holds a single character.

16
New cards

boolean

Logical true/false type.

17
New cards

Literal

A fixed constant value written directly in code, such as 317, 3.14, true, 'A', or "Hello".

18
New cards

Char literal

A single character enclosed in single quotes, e.g., 'A' or '\t'.

19
New cards

String literal

A sequence of characters enclosed in double quotes, e.g., "Hello World"; distinct from a char literal.

20
New cards

Escape sequences

Special character sequences like \t, \r, \n, \' and \ used inside character or string literals.

21
New cards

Unicode escape

A character literal like '\u00E9' representing a Unicode code point.

22
New cards

Numeric literals

Decimal numbers; may include exponential form (e notation); real numbers with a decimal point or exponent are doubles by default.

23
New cards

Underscores in numeric literals

You can use underscores in numeric literals for readability, e.g., 2000000_000.

24
New cards

Binary/Octal/Hex literals

Numeric literals can be binary (0b…), octal (leading 0), or hexadecimal (0x…); the bases use 0-9 and A-F (case-insensitive).

25
New cards

Boolean literals

Two constants of type boolean: true and false.

26
New cards

String

A non-primitive object type representing a sequence of characters; String literals use double quotes.

27
New cards

String vs char

Char is a single character; String is a sequence of characters; they are different types.

28
New cards

Literals vs variables

Literals are fixed values in code; variables store values that can change during execution.

29
New cards

Arithmetic operators

+, -, *, / are the basic arithmetic operators; can be applied to numeric types and char treated as integers.

30
New cards

Type conversion

Automatic or explicit conversion between numeric types; e.g., int to double; mixing int and double may promote to double.

31
New cards

Integer division caveat

Dividing two integers yields an integer result (fraction discarded). To get a real result, cast to double or use a double literal.

32
New cards

Modulo operator

The % operator returns the remainder of division; behavior with negative values is implementation-defined for Java.

33
New cards

Increment/Decrement

++ and -- operators; post-increment (x++) returns old value, pre-increment (++x) returns new value; similarly for decrement.

34
New cards

String concatenation with +

Using + with a String and another type results in a String; automatic conversion to String occurs.

35
New cards

Relational operators

Compare values: ==, !=,

36
New cards

Double.NaN

A special double value representing Not-a-Number; comparisons with NaN behave unexpectedly; use Double.isNaN(x) to test.

37
New cards

Boolean operators

Logical AND (&&), OR (||), and NOT (!) with short-circuit evaluation.

38
New cards

Conditional operator

The ternary operator expression: condition ? expr1 : expr2; returns one of two expressions based on the boolean condition.

39
New cards

Assignment operators

Compound assignments like +=, -=, *=, /=, %= are shorthand for applying an operation then assigning the result.

40
New cards

Precedence rules

Operator precedence determines evaluation order; multiplication/division bind tighter than addition/subtraction; parentheses can override.

41
New cards

Subroutine (method)

A block of code inside a class used to perform a task; can be static or instance (non-static); may return a value.

42
New cards

Return statement

Used in a function to exit and produce a value; a void method uses return; non-void methods must return a value.

43
New cards

Formal vs actual parameters

Formal parameters are the names in a method definition; actual parameters are the values supplied in a method call.

44
New cards

Overloading

Having multiple methods with the same name but different parameter signatures within a class.

45
New cards

Static vs non-static

Static members belong to the class; non-static (instance) members belong to objects; static data is shared.

46
New cards

Main method

The program entry point: public static void main(String[] args).

47
New cards

Constructor

A special method with no return type and same name as the class; used to create and initialize objects; can be overloaded.

48
New cards

new operator

Creates a new object and returns a reference to it; calls the constructor.

49
New cards

Null

A special value for reference variables indicating no object is referenced; dereferencing causes NullPointerException.

50
New cards

Garbage collection

Java's automatic memory management that reclaims objects that are no longer reachable.

51
New cards

Object vs class

A class is a blueprint; an object is an instance created from a class; objects have their own data (instance variables) and behavior (methods).

52
New cards

Instance vs static members

Instance members belong to objects; static members belong to the class and are shared across all instances.

53
New cards

Equals vs '==' for objects

'==' checks reference equality; .equals() checks value/content equality for objects like Strings.

54
New cards

Arrays

A fixed-length, ordered collection of elements of the same base type; arrays are objects; elements are accessed by index starting at 0.

55
New cards

For-each loop

Enhanced for loop: for (Type item : array) { … } to iterate over elements without using indices.

56
New cards

Exception handling

Try-catch blocks to handle runtime errors; exceptions can be NumberFormatException, IllegalArgumentException, etc.