Q1.
Guess Before You Run
int a = 7;
int b = 2;
[Link](a / b);
[Link](a % b);
Task: Before running this, write down on paper what YOU think the output is. Then
run it and check.
If you got it wrong: That's fine — that's exactly why this question exists. Now you'll
never forget it.
Q2. Data Type Detective
Task: Declare one variable of each type: int , double , char , boolean ,
String . Print all five. Then try this:
int x = 5;
double y = x; // does this work?
double z = 5.9;
int w = (int) z; // what does w print?
Predict the output of w before running.
Q3. The Boolean Flip
Task: Write a program that takes a boolean isRaining and prints "Take umbrella"
or "Leave it home" — using only if-else . Then rewrite it using the ternary operator
?: in one line.
STAGE 2 — Loops (train your brain to "see" the repetition)
Q4. Print 1 to N — Three Ways
Task: Print numbers 1 to 10 using: a for loop, a while loop, and a do-while
loop. All three should give the exact same output.
Why this matters: Beginners often "know" all three loop types but freeze when
asked to pick one. Writing the same logic three ways proves to your brain they're
interchangeable — so later you can just pick whichever fits, not panic about "which
loop am I supposed to use."
Hint if stuck: Every loop needs 3 things: a starting point, a condition to keep
going, and a step that changes the variable. Find these 3 things in each version.
Q5. Sum and Count Together
Task: Print numbers 1 to 20, but also keep a running total, and at the end print the
sum. (i.e., loop does two jobs at once: printing AND adding.)
Q6. Even or Odd Counter
Task: Loop from 1 to 30. Count how many numbers are even and how many are odd.
Print both counts at the end.
STAGE 3 — Arrays (the moment things start feeling "real")
Q7. Print an Array, Then Print it Backwards
Task: Given int[] arr = {10, 20, 30, 40, 50}; , print it forward using a loop,
then print it backward using a different loop.
Q8. Find the Largest Number (by hand-logic, not a built-in function)
Task: Given an array of 6 numbers, find the largest without using [Link]() or
sorting — using a loop and one variable that "remembers" the biggest number seen
so far.
Hint if stuck: Start by assuming the first element is the largest ( int max =
arr[0]; ). Then for every OTHER element, ask: "Is this one bigger than what I
have?" If yes, update max .
Q9. Count How Many Times a Number Appears
Task: Given int[] arr = {2, 5, 2, 8, 2, 9, 2}; , count how many times 2
appears using a loop and a counter.
Q10. Add Up Only the Even Numbers
Task: Given an array of 10 numbers, add up only the even ones, and separately
count how many odd ones there were.
STAGE 4 — Strings (characters ARE just small puzzles)
Q11. Count the Vowels
Task: Given a string like "Pratik loves Java" , count how many vowels (a, e, i,
o, u — both cases) it contains, using a loop and charAt(i) .
Q12. Count Uppercase and Lowercase Letters Separately
Task: Given a sentence, count how many uppercase letters and how many
lowercase letters it has.
Q13. Simple Palindrome Check (Beginner Version)
Task: Check if a word like "madam" reads the same forwards and backwards. It's
OK to use new StringBuilder(str).reverse().toString() and compare —
the advanced two-pointer version comes later, once this is solid.
STAGE 5 — Small Combination Questions (put it all together, gently)
Q14. Simple Pattern — Just a Square and a Triangle
Task: Using nested loops, print:
* * * * *
* * * * *
* * * * *
Then print a simple triangle:
*
* *
* * *
* * * *
Q15. FizzBuzz (The Real Beginner Version)
Task: Print numbers 1 to 30. If divisible by 3, print "Fizz" instead. If divisible by 5,
print "Buzz" instead. If divisible by both, print "FizzBuzz" instead.