1/18
A complete set of flashcards covering key concepts, syntax, data types, memory mechanics, and control flow from the Mastering Java Fundamentals guide.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Who created Java, in what year, and at what company was it created?
Java was created by James Gosling in 1995 at Sun Microsystems, which was later acquired by Oracle in 2010.
What were the original names of Java before it was officially named Java?
Java was originally named 'Oak' (after an oak tree outside James Gosling's office) and was later renamed to 'Green' before becoming 'Java'.
What are the four editions of the Java platform?
What are the two main phases of executing a Java program?
What is the exact signature of the entry point main method in Java?
public static void main(String[] args)
What naming conventions are used for Java classes versus Java methods and variables?
Classes use the Pascal Naming Convention (e.g., Main, MyFirstClass). Methods and variables use the Camel Naming Convention (e.g., main, sendEmail, myAge).
What are the 8 primitive data types in Java and their memory sizes?
byte (1 byte), short (2 bytes), int (4 bytes), long (8 bytes), float (4 bytes), double (8 bytes), char (2 bytes), and boolean (1 byte).
How does memory allocation differ when copying Primitive Types versus Reference Types?
Primitives are copied by value, storing independent values in separate memory slots. Reference types are copied by reference, copying the memory address pointer so both variables point to the exact same object in memory.
Why are String objects described as immutable in Java?
Any String method that modifies text (such as trimming or replacing characters) always returns a brand-new String object rather than altering the original string.
What are the rules and default values for Java arrays?
Java arrays are reference types with a fixed length that cannot be changed once created. Uninitialized array slots default to 0 for numbers, false for booleans, or empty strings.
Which methods are used to convert single-dimensional and multi-dimensional arrays into readable String representations?
Arrays.toString() is used for single-dimensional arrays, and Arrays.deepToString() is used for multi-dimensional arrays.
How do you define a constant in Java, and what is its naming convention?
Prepend the keyword final to the variable declaration. By convention, constant names are written in all-uppercase letters.
What is the difference between prefix (++x) and postfix (x++) increment operators?
Postfix (x++) copies the original value to the left side expression first and then increments the variable. Prefix (++x) increments the variable first before assigning or evaluating the value.
How do implicit casting and explicit casting differ in Java?
Implicit casting happens automatically when converting a smaller type to a larger compatible type without data loss. Explicit casting is manually required when converting a larger type to a smaller type by prefixing the target type in parentheses, which risks data loss.
Why can you not use the 'new' operator to instantiate the NumberFormat class?
NumberFormat is an abstract class, so you must call factory methods such as NumberFormat.getCurrencyInstance() or NumberFormat.getPercentInstance() instead of using new.
What data types are supported in Java switch statements?
Switch statements support bytes, shorts, ints, and strings.
What is the main operational difference between a while loop and a do-while loop?
A while loop evaluates its condition before running the code block, whereas a do-while loop evaluates its condition at the end, guaranteeing the block executes at least once.
What are two major limitations of a Java for-each loop?
It is forward-only and does not provide access to the loop index.
What is the difference between scanner.next() and scanner.nextLine()?
scanner.next() reads only a single token and stops at whitespace, whereas scanner.nextLine() reads the entire line of input including spaces.