Distinguish between the break and the continue statements.
Iterative Constructs
Original Khojo Papers practice question — not from a past board paper.
boolean prime = n > 1; for (int i = 2; i * i <= n; i++) if (n % i == 0) { prime = false; break; } System.out.println(prime ? "Prime" : "Not prime");
No citable source has been recorded for this record. Treat it as practice material, not as fact.
Testing divisors only up to the square root is enough, because a factor above it would pair with one below it.
From the same topic and chapter, at a similar level.
Distinguish between the break and the continue statements.
Iterative Constructs
How many times does the body of this loop execute: for (int i = 10; i > 0; i -= 3) { … }
Iterative Constructs
State three differences between a while loop and a do-while loop.
Iterative Constructs
Write a Java program segment to find the sum of the first n natural numbers using a for loop.
Iterative Constructs
Explain the ternary operator in Java and rewrite "if (a > b) max = a; else max = b;" using it.
Operators and Expressions in Java
What is the output of: String s = "Examination"; System.out.println(s.length() + " " + s.substring(0, 4) + " " + s.toUpperCase().charAt(2));
String Handling