A curated collection of fundamental Java programs designed to strengthen your basics, logic building, and problem-solving skills — the perfect foundation before diving into Data Structures & Algorithms (DSA).
These exercises cover conditionals, loops, functions, and pattern printing, helping you master Java syntax and core programming logic.
PRE-DSA-PRACTICE-SET/
│
├── 01basic/ # Basic logic and condition-based programs (33 questions)
│ ├── EvenOddFirst.java
│ ├── Product.java
│ ├── LeapYear.java
│ ├── SimpleCalculator.java
│ └── ...
│
├── 02loop/ # Programs using loops (for, while, do-while)
│
├── 03function/ # Programs using user-defined functions
│
├── 04basic2/ # Advanced logic-based programs (Perfect No., Palindrome, etc.)
│
└── 05pattern/ # 36 pattern problems (stars, numbers, alphabets)
├── StarPattern1.java
├── StarPattern2.java
└── ...
- Print statements and simple calculations
- Arithmetic operations (product, average, area of circle)
- Conditional statements (
if-else,switch) - Even or odd (multiple approaches)
- Simple calculator using switch
- Leap year check
- Largest among numbers
- Day of week using switch
- Swap two numbers (with & without third variable)
- Print numbers using
for/whileloop - Sum and product of natural numbers
- Reverse a number
- Factorial of a number
- Multiplication table
- Keep entering numbers until a condition is met
- Product of two numbers using a function
- Binomial coefficient (
nCr) - Prime number check (optimized)
- Print primes in a range
- Prime factors of a number
- Print first N natural numbers
- Perfect number check
- Count digits / Sum of digits
- X raised to power Y
- Fibonacci series
- Palindrome number
- Armstrong number
- LCM and HCF
- Convert Binary ↔ Decimal
Includes 36 pattern problems using nested loops:
- Right-angled & inverted triangles
- Pyramids and diamonds
- Number & alphabet patterns
- Mirror and combined patterns
Each file (StarPattern1.java → StarPattern36.java) demonstrates unique loop logic, helping you master nested iteration and space control.
This practice set is designed to:
- Strengthen core programming fundamentals
- Improve logical and analytical thinking
- Prepare you for Data Structures & Algorithms (DSA)
- Build confidence in Java syntax & problem solving
After completing these, you’ll be fully ready to tackle Arrays, Strings, Recursion, and beyond.
- Language: Java
- Editor: Visual Studio Code
- Execution: Command line or integrated terminal
# Step 1: Compile the program
javac FileName.java
# Step 2: Run the compiled class
java FileNameEbadur Rahman 💼 Software Developer | MERN Stack | Laravel | PHP 🔗 LinkedIn
You can:
- Fork the repo and solve the same problems in another language
- Add new questions or optimize existing solutions
- Suggest improvements or alternative logic
Once you complete this set, move on to:
- Arrays & Strings
- Searching & Sorting
- Recursion
- Linked List, Stack, Queue
- Tree & Graph
- Dynamic Programming (DP)
“Master the basics — everything else becomes easier.”