1/82
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.

What’s missing
static void

What’s missing
.println

What’s missing?
System.out

What’s missing?
String[] args
How can you make the integer literal 1000000 more readable in Java code without changing its value?
Use underscores to separate blocks. Example: int num = 1_000_000;
Identify the data type of 'A'
char
Identify the data type of “A”
String
Identify the data type of 123
int
What is the difference between these two literals? 1 vs '1'
1 is an Integer (used for math/counting).
'1' is a Character (just a symbol, like a letter).
Spot the error in this code: char letter = "B";
Type Mismatch.
What is the relationship between a Method and a Block?
A Method is a named operation that contains a Block as its body
Method = Name + Block
Block = Just the code inside {}
I look like this: ; What am I in Java, and what do I signify?
I am a Semicolon. I mark the end of a Statement
I look like this: { ... } What is the name for the group of statements inside me?
A Block.
I look like this: // or /* What comes after me?
Comments.
If you write a variable name like public or class, Java will stop you. Why?
Because they are Keywords. (These are reserved words
In "Sequential Flow," in what order does the computer read your code?
Top to Bottom.
What do we call the strict set of grammar rules
Syntax
I am a specific word chosen by you to name a variable or a function. What am I?
An Identifier. (Example: In int apples = 5;, the word apples is the identifier.)
I am a sequence of statements grouped together to perform a "high-level operation" (a subprogram). What am I?
A Method.
I include spaces, tabs, and newlines. You cannot see me on the screen, but I help organize the code. What am I?
Whitespace.
Why is the main method essential?
It makes the program runnable. (Without it, the program has no "Entry Point" and cannot start.)
Is the word main considered a Java keyword?
No. (It is a predefined method name
If you name the method Main (capital M) instead of main (lowercase m), will it work?
No. (Java is case-sensitive. It must be exactly main.)
What does String[] args represent in the main method?
It represents arguments
What specific character must be used to end every statement in Java?
A semicolon ;
What does the println method do that a normal print command might not?
It displays the string followed by a new line
In the code System.out.println("Hello");, is the text "Hello" a keyword or identifier?
Neither. (It is just a String literal(

Spot the Error
Class Name: Starts with a digit (1MyProgram).
Method Name: Capitalized (Main should be main).
Missing Semicolon: After the print statement.
If I want to print the result of math (like 5 + 5 = 10), which format must I use?
System.out.println(5 + 5)
What is the main difference between System.out.println() and System.out.print()?
println prints text and moves the cursor to the next line.
print prints text and keeps the cursor on the same line.
What happens if you run System.out.println(); with nothing inside the parentheses?
It prints an empty line.
When the program prints a String (like "Hello") or a Char (like 'A'), do the quote marks appear on the screen?
No. The quotes are just containers for the code; only the text inside is displayed.
What is the "Escape Character" used to insert a new line inside a single string?
\n
What will this code output? System.out.print("A\n\nB");
A
B
Can System.out.print handle numbers (like 108) without quotes?
Yes
What is the output of this code? System.out.println(3 + 3 + " is the result")
6 is the result
What is the output of this code? System.out.println("Result: " + 3 + 3);
Result: 33
In the code String message = "Hi";, is message the variable or the identifier?
message is the Identifier (the name).
Is 1stPlayer a valid variable name? Why or why not?
No. Variable names (identifiers) cannot start with a digit.
Does Java treat score and Score as the same variable?
No. Java is case-sensitive.
How do you declare multiple variables of the same type on a single line?
Separate them with a comma. Example: String name = "John", lastName = "Doe";
Since Java 10, which keyword allows the computer to automatically guess the variable type based on the value?
var (Type Inference). Example: var age = 10; (Java treats this as an int).
int price = 100;
price = "Free";Type Mismatch
var data;
data = 10;Missing Initialization. When using var, you must assign a value immediately so Java can guess the type. You cannot split declaration and initialization with var.
int a;
a = 50;Yes. It is valid to declare a variable first (int a;) and initialize it later (a = 50;), though doing it on one line is preferred.
What is the famous 4-word phrase that describes Java's platform independence?
Write once, run anywhere
To run a program, the java tool opens a file with which specific extension?
.classDoes the JVM understand high-level languages like Java or Kotlin directly?
No. The JVM only understands Java Bytecode.
Is the code that goes into the JVM platform-independent or platform-dependent?
Platform-Independent
Name three "JVM Languages" (languages that compile to bytecode).
Java
Kotlin
Scala (Also: Groovy, Clojure)
If a user enters "150" using sc.next(), what Java Data Type does the program store this value as?
A String
What is the advantage of using a method like sc.nextInt() instead of just sc.next()?
sc.nextInt() reads the input directly as an integer type, making it easier to perform mathematical operations immediately.
To get the 3 digit of a three-digit in 320?
(320 %1000)/100
To get the 2 digit of a three-digit in 320?
(320 % 100) /10
To get the 0 digit of a three-digit in 320?
320 % 10
Simplify a = a + b.
a+=bSimplify a = a / b.
a /=b
int x = 10;
int y = ++x; y=?
11
What is the final value of y in this postfix example?
int x = 10;
int y = x++;10
If you want text to print on the same line but appear in separate, aligned columns, which escape sequence should you use?
\t (Tab)
What is the core reason why you must type \\ to get a single backslash in your output?
Because the single backslash (\) is the escape character—it must be escaped itself to lose its special meaning
You are defining a String: "He said, "Yes"". Which escape sequence is missing to make this valid?
\" (The code should be: "He said, \"Yes\"")
What is the primary visual difference between the behavior of \r (Carriage Return) and \n (Newline)?
r moves the cursor back to the start of the same line (causes overwriting), while \n moves the cursor to the start of the next line.
String name = "Java";
char charA = name.charAt(4);StringIndexOutOfBoundExceptionString nothing = null;
boolean check = nothing.startsWith("J");nullPointerException
String empty = "";
boolean check2 = empty.isEmpty();true
String data = " Java Program ";
data.trim().toUpperCase()JAVA PROGRAM
String code = "123ABCD";
code.substring(3, 6)ABC
String data = " Java Program ";
data.contains("P") && data.endsWith(" ")true
What does the expression 1.5e3 represent mathematically?
$1.5 \times 10^3 = \mathbf{1500.0}$
Between float and double, which type does Java programmers typically recommend and use due to its higher precision?
double (14-16 significant digits).
double x = 10;
System.out.println(x / 4);2.5
System.out.println(10 / 4);
2
boolean value = 0. what the result
Error cant convert 0 to logic
In a single sentence, describe the condition under which the XOR (^) operator returns true.
t returns true only if the two operands have different values (one true and one false
What logical operator has the highest precedence, meaning it is always evaluated first unless overridden by parentheses?
The NOT operator (!)
In the expression (false && [Complex Expression]), does the JVM bother to evaluate the right side? Why or why not?
No. This is short-circuit evaluation. Since the first operand of && is false, the entire result must be false, so the right side is skipped to save computation time.
you have (true || [Expression]), what will the overall result be, and why
The result will be true. The JVM stops (short-circuits) because one true is enough to satisfy the || operator.
boolean isCold = false;
boolean isRainy = true;
boolean isSummer = false;
!isRainy || isColdFalse
boolean isCold = false;
boolean isRainy = true;
boolean isSummer = false;
isRainy && (isCold ^ isSummer)false
boolean isCold = false;
boolean isRainy = true;
boolean isSummer = false;
(isSummer || isRainy) && !isColdtrue
What is the final value of b based on the operator precedence rules?
boolean x = true;
boolean y = false;
boolean b = x || !y && y;true
boolean checkStatus() {
System.out.println("Checking Status...");
return true;
}
public static void main(String[] args) {
if (false && checkStatus()) {
System.out.println("Go");
} else {
System.out.println("Stop");
}
}false