Thuta Learning
ExercisesProgrammingbeginner

Practice Set 1: Fundamentals & OOP

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Work through Practice Set 1: Fundamentals & OOP on your own
  • Practice the skills you've already learned to make them solid
  • Get better at finding bugs, fixing them, and checking your own work

Take a Moment to Think

This lesson isn't a teaching lesson — it's a set of tasks for practicing on your own the core fundamentals you learned in the Basic and Intermediate chapters. You'll get hands-on again with variables, operators, if-else/switch conditions, loops, arrays, and simple class/object creation. Writing and running each task yourself is what makes these concepts stick. We recommend thinking it through and giving each task your own attempt before checking the solution.

Exercises

Task 1: Use variables and operators to convert a Celsius temperature to Fahrenheit, then print it out using String concatenation. Task 2: Write a program that uses a switch statement — when you enter a number from 1 to 7, it prints the matching day name (Monday, Tuesday, ...). Task 3: Build an array of 10 integers, loop through it with a for loop, and find the max value and the sum. Task 4: Build a Book class (with title, author, price fields, a constructor, and a printInfo() method), create 3 Book objects in main, and call printInfo() on each.

Code Example

java
import java.util.Scanner;

public class Practice1 {
    public static void main(String[] args) {
        // Task 1: Celsius to Fahrenheit
        double celsius = 30.0;
        // TODO: formula နဲ့ fahrenheit ကို calculate ပြီး print လုပ်ပါ

        // Task 2: Switch statement for day name
        int day = 3;
        // TODO: switch ကိုသုံးပြီး day name ကို print ပါ

        // Task 3: Array max & sum
        int[] numbers = {12, 45, 7, 89, 23, 56, 3, 90, 15, 34};
        // TODO: for loop နဲ့ max value နှင့် sum ကို ရှာပါ

        // Task 4: Book class
        // TODO: Book class (title, author, price) + printInfo() method ကိုရေးပါ
    }
}
You should see
For all 4 tasks, your program should print the correct output to the console — the Fahrenheit value, the day name, the max/sum numbers, and the info for all 3 books.

Try It in 5 Minutes

Bump Task 3's array size up to 20, fill it with some random-ish numbers, and re-test your max/sum logic within 5 minutes.

A Quick Heads-Up

For each task, spend at least 5-10 minutes thinking it through and giving it a genuine try before looking at the solution — this habit makes the concepts stick far better.

Easy traps

  • Forgetting to add break inside a switch statement, causing fall-through into the next case
  • Writing the Fahrenheit formula (celsius * 9/5 + 32) with 9/5 as integer division, which evaluates to 1 (you should write 9.0/5 instead)

Now Try It Yourself

Bump Task 3's array size up to 20, fill it with some random-ish numbers, and re-test your max/sum logic within 5 minutes.

You'll know it worked when: For all 4 tasks, your program should print the correct output to the console — the Fahrenheit value, the day name, the max/sum numbers, and the info for all 3 books.