PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

Java Operators

← All stacks

Theory

13/270

Java Operators

Operators do work on values. + - * / % for maths. % is remainder — handy for even/odd. 5 / 2 is 2 in int maths, not 2.5. That surprise fails many viva questions.

> < >= <= == != compare and give true or false. && || ! join conditions. = assigns. == compares. x += 1 is x = x + 1.

condition ? a : b is a short if-else. The classic bug is writing = inside if when you meant ==. In an exam, show both traps: = vs ==, and 5/2 becoming 2.

Let's take this on the board with one tiny Main class — no extra files. Java Operators — output: 1 then true. 10 % 3 is 1. 10 > 3 && 3 > 0 is true. Start from main, go line by line, and stop at each print. That output is the proof for Operators.

Exam tip

Show two traps: = vs ==, and 5/2 becoming 2 (int division).

Example

public class Main {
  public static void main(String[] args) {
    int a = 10, b = 3;
    System.out.println(a % b);
    System.out.println(a > b && b > 0);
  }
}

Java Operators — output: 1 then true. 10 % 3 is 1. 10 > 3 && 3 > 0 is true.

Short notes

  • DefOperators do work on values — maths, compare, assign, join conditions.
  • Rule% = remainder. 5 / 2 → 2 in int maths, not 2.5.
  • Diff= assigns. == compares.
  • TrapWriting = inside if when you meant ==.

Questions

1

What is % ?

2

What is 5 / 2 in int maths?

3

= vs == ?

Previous← Unicode System in JavaNextJava Keywords →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.