AlgoMaster Logo

Basic Syntax - Quiz

Last Updated: May 18, 2026

1 min read

Basic Syntax Exercises

14 quizzes

1
Code Completion

Build a label where the two numeric values are added before text is attached.

java
1
String label = "Total: " + ;

Click an option to fill the blank:

2
Code Completion

Use the current order ID for this order, then advance the stored ID for the next order.

java
1
int assignedOrderId = nextOrderId;

Click an option to fill the blank:

3
Multiple Choice

A method declares a local variable for shipping cost, assigns it only inside an if branch, and then reads it after the branch. What happens at compile time?

4
Multiple Choice

An order total in cents is larger than the int range, and a developer wants to store it directly in a long variable using a decimal numeric literal. What must be true of the literal?

5
Multiple Choice

A user name is built at runtime in two separate String objects, both with the same characters. The program compares them with ==. What does that comparison test?

6
Multiple Choice

A shipping report divides total packages by vans, both stored as int, and assigns the result to a double. The decimal part is missing. What change addresses the cause?

7
Multiple Choice

A program reads a quantity with Scanner.nextInt() and then immediately reads a product name with Scanner.nextLine(). The name appears empty. What caused this?

8
Fill in the Blanks

Complete the code to represent a missing coupon code using a reference value

java
1
couponCode = ;
2
System.out.println(couponCode);

Click an option to fill blank 1:

9
Fill in the Blanks

Complete the formatted output for product name and price

java
1
String productName = "Mug";
2
double price = 12.5;
3
System.out.("Product: %s Price: %.2f%n", , price);

Click an option to fill blank 1:

10
Fill in the Blanks

Complete the input reads for an integer quantity and a decimal unit price

java
1
java.util.Scanner scanner = new java.util.Scanner(System.in);
2
int quantity = scanner.();
3
double unitPrice = scanner.();

Click an option to fill blank 1:

11
Matching

Match each numeric scenario to what Java does

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

12
Matching

Match each commenting situation to the most appropriate choice

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

13
Sequencing

Order the steps for reading a numeric line of input and using it in a calculation

Drag and drop to reorder, or use the arrows.

14
Sequencing

Order what happens when creating an array, storing a value, and reading it through a reference

Drag and drop to reorder, or use the arrows.

Premium Content

Subscribe to unlock full access to this content and more premium articles.