Skip to content
Learn Netverks

Lesson

Step 8/36 22% through track

operators

Operators and expressions

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Operators and expressions: the syntax, APIs, and habits you need before advancing in Java.

Teams ship Operators and expressions on every Java codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Operators and expressions in contexts like: Spring Boot APIs, banking systems, Android (with Kotlin), and batch/data pipelines on the JVM.

Write Java with a public class (lessons use Main), click Run on server—the dev runner runs javac then java; fix compile errors from stderr (LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

Java operators mirror C-style languages: arithmetic, comparison, logical, and assignment. Operator precedence matters—use parentheses when clarity beats memorization.

Arithmetic and assignment

int a = 10, b = 3;
System.out.println(a / b);      // 3 — integer division
System.out.println(a % b);      // 1 — remainder
a += 2;

Comparison and logical

  • ==, !=, <, > — compare primitives; for objects use equals
  • &&, ||, ! — short-circuit boolean logic
  • instanceof — type check at runtime

Important interview questions and answers

  1. Q: Why does 10 / 4 equal 2 in int math?
    A: Integer division truncates toward zero; cast to double for fractional results.
  2. Q: == on Strings?
    A: Compares references unless interned; use equals for value equality.

Self-check

  1. What is the result of 17 % 5?
  2. When should you use equals instead of ==?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • == on objects risk?
  • Short-circuit && why?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump