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

Java · Theory

Control Statements in Java

← All stacks

Theory

15/270

Control Statements in Java

Control statements decide which lines run and how many times. Real programs are not a straight list — they react to marks, menus, and input.

Three groups. Decision: if, else, switch pick a path. Loop: for, while, do-while repeat work. Jump: break stops a loop or switch; continue skips one round.

Learn if and for first. Then switch, while, break, continue. A loop with no stop condition never ends — say that in the viva.

Let's take this on the board with one tiny Main class — no extra files. Control Statements in Java — output: Pass. marks is 72, >= 40, so if runs. Change marks to 35 in your head — else prints Fail. Start from main, go line by line, and stop at each print. That output is the proof for Control Statements.

Exam tip

Say three groups: decision + loop + jump. One example each.

Example

// Control statements overview
public class Main {
  public static void main(String[] args) {
    int marks = 72;
    if (marks >= 40) {
      System.out.println("Pass");
    } else {
      System.out.println("Fail");
    }
  }
}

Control Statements in Java — output: Pass. marks is 72, >= 40, so if runs. Change marks to 35 in your head — else prints Fail.

Short notes

  • DefControl statements decide which lines run and how many times.
  • RuleDecision = if/switch. Loop = for/while. Jump = break/continue.
  • RememberLearn if + for first. Then the rest.
  • TrapA loop with no stop condition never ends.

Questions

1

Name the three groups of control statements.

2

Give one example of each.

Previous← Java KeywordsNextJava If-else Statement →
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.