๐Ÿ“Š We use cookies & analytics to improve your experience. Learn more
Latest

Free course ยท Beginner

Java Programming Foundations

๐Ÿ› Way2Fresher Academy โฑ 8 weeks โญ 4.7 ๐Ÿ‘ฅ 9,100 learners ๐ŸŽ“ Certificate

Free 5 modules ยท 15 lessons Start now โ†’

What you will learn

  • Set up the JDK and an editor, and run a class from the terminal without copying commands you do not understand
  • Use types, variables and casting correctly, and know why an int divided by an int loses the decimals
  • Write classes with constructors, fields and methods โ€” the object model interviews start from
  • Choose between ArrayList and HashMap for a given job, and say why out loud
  • Handle exceptions with try-with-resources instead of letting the program die
  • Answer the twenty Java questions fresher interviews repeat, with an example for each

Course curriculum

5 modules ยท 15 lessons ยท a worked example and a practice task in every lesson

Module 3Exceptions, files and the interview set3 of 53 lessons

Weeks 6โ€“8 โ€” handling failure, reading real data, and rehearsing the questions that decide the outcome.

  1. Exceptions and try-with-resources

    Checked exceptions must be handled or declared, unchecked ones are usually bugs. Neither should ever be swallowed with an empty catch block โ€” that is how a system fails silently.

    The lesson

    An exception is a failure travelling up the call stack until somebody handles it. try { โ€ฆ } catch (IOException e) { โ€ฆ } finally { โ€ฆ } is the shape: the risk in the try, the handling in the catch, the clean-up in finally โ€” and throw new IllegalArgumentException("age must be positive") is how your own code reports a bad input rather than returning a wrong number.

    Checked exceptions must be declared or caught, which is why file work in Java looks noisy: throws IOException on the method, or a catch around it. try-with-resources โ€” try (BufferedReader r = Files.newBufferedReader(path)) { โ€ฆ } โ€” closes the file for you even when it throws, which is the modern replacement for a finally block.

    The mistakes are an empty catch block that swallows the error silently, which turns a bug into mysterious missing data, and catching Exception everywhere so nothing is ever reported precisely. Catch the narrowest type you can, and always do something with it: log it or tell the user.

    Java
    try {
        int n = Integer.parseInt("abc");
    } catch (NumberFormatException e) {
        System.out.println("Not a number: " + e.getMessage());
    } finally {
        // runs whether or not an exception was thrown
    }
    
    // try-with-resources closes the reader for you, even on error.
    try (BufferedReader r = new BufferedReader(new FileReader("data.txt"))) {
        String line;
        while ((line = r.readLine()) != null) System.out.println(line);
    } catch (IOException e) {
        System.out.println("Could not read: " + e.getMessage());
    }

    Example try (BufferedReader r = new BufferedReader(new FileReader(path))) closes the file even when the read throws. Using plain FileReader without try-with-resources leaks a file handle every time.

    Practice Read a file, handle a missing filename and a malformed line separately, and print a different message for each. Never leave a catch block empty.

  2. Reading a file and writing a report

    Reading a CSV into objects and writing a summary out is the shape of the first task in most enterprise teams. It is also the smallest project that proves you can work in a real codebase.

    The lesson

    The fresher file task is always the same: read a CSV, do something to each row, write a report. Files.readAllLines(Path.of("data.csv")) gives you the lines, splitting each on a comma gives you the fields, and Files.writeString or a BufferedWriter writes the output.

    Write it as three methods โ€” read, process, write โ€” and the whole thing becomes testable and explainable in an interview. Handle a missing file with a readable message rather than a stack trace, and skip the blank last line rather than crashing on it, which is what real exports always contain.

    The mistakes are hard-coding an absolute path from your own laptop, and using split(",") on text where a field contains a comma inside quotes. Use line.split(",", -1) so trailing empty fields are kept, and print the first three rows before trusting any of the parsing.

    Java
    Map<String, Integer> totals = new LinkedHashMap<>();
    try (BufferedReader r = new BufferedReader(new FileReader("raw.csv"))) {
        r.readLine();                                  // skip the header
        String line;
        while ((line = r.readLine()) != null) {
            String[] cells = line.split(",");
            if (cells.length < 3 || cells[1].isBlank()) continue;
            totals.merge(cells[1].trim(),
                         Integer.parseInt(cells[2].trim()), Integer::sum);
        }
    }
    try (PrintWriter w = new PrintWriter("report.csv")) {
        totals.forEach((city, n) -> w.println(city + "," + n));
    }

    Example Reading line by line with split(",") and building a Student per line gives you a list you can total, sort and print โ€” the same program an MIS team would ask a fresher to write.

    Practice Add a malformed line to your CSV on purpose and make the program report the line number and keep going instead of crashing.

  3. The twenty questions fresher interviews repeat

    The written round and the technical interview ask the same core set every year: String immutability, equals versus ==, the four pillars, ArrayList versus LinkedList, HashMap internals, and "what happens when an exception is thrown".

    The lesson

    The same questions come back in almost every fresher Java round, so they are worth answering from memory: the difference between == and .equals(), ArrayList against LinkedList, String against StringBuilder, what a constructor does, method overloading against overriding, the four OOP pillars with your own example, and what a HashMap collision is.

    Also in the set: checked against unchecked exceptions, final against finally, why main is static, what the JVM is doing when you run java Hello, what an interface is for, and a small problem โ€” reverse a string, count characters, find the second largest in an array โ€” written in front of them.

    The mistake is memorising definitions without an example. "Polymorphism is having many forms" scores nothing next to "in my project, one Notification interface had an email and an SMS implementation". Prepare one line of your own for each, and the round stops feeling like a viva.

    Plain text
    Overload vs override . == vs .equals() . String immutability .
    ArrayList vs LinkedList vs HashMap . checked vs unchecked exceptions .
    interface vs abstract class . final vs static . pass-by-value .
    HashMap internal working . garbage collection . throw vs throws .
    constructor chaining . Comparable vs Comparator.
    
    Answer each in three lines: what it is . why it exists . one code sketch.

    Example Rehearse each answer out loud with one example from your own code. "I used a HashMap in this project because..." beats a definition every time.

    Practice Record yourself answering all twenty in under a minute each, then listen back once and note which answers went vague.

Show all modules on one page

About Java Programming Foundations

Read, write and debug Java the way a first job asks for it โ€” classes, collections, exceptions and a small console application you can explain.

Engineering and MCA students, and anyone targeting the mass-hiring drives where Java and SQL are the two skills on the paper. Especially useful if college taught you syntax and never made you build anything.

What you will be able to do at the end

  • Set up the JDK and an editor, and run a class from the terminal without copying commands you do not understand
  • Use types, variables and casting correctly, and know why an int divided by an int loses the decimals
  • Write classes with constructors, fields and methods โ€” the object model interviews start from
  • Choose between ArrayList and HashMap for a given job, and say why out loud
  • Handle exceptions with try-with-resources instead of letting the program die
  • Answer the twenty Java questions fresher interviews repeat, with an example for each

How the course is structured

3 modules and 9 lessons, arranged so each one ends with something you have built. Every lesson carries a worked example and a practice task โ€” the practice is the course, the reading is only the setup. Plan for 8 weeks ยท about 6 hours a week.

The full syllabus โ€” every lesson, its example and its practice task โ€” is in the Course curriculum below. Nothing is locked and nothing needs an account.

Your weekly routine

  • Three 2-hour blocks a week, one of them spent only typing code, not reading.
  • Ten minutes on the last session before starting the next one, re-reading your own code.
  • One timed written-test practice set every fortnight.

What you will have built by the end

  • A student marksheet program โ€” reads a CSV, computes totals and grades, writes a report
  • A small library or inventory manager using classes, an interface and two collection types
  • A written answer sheet for the twenty repeating interview questions, each with an example from your own code

Where this leads for a fresher

  • Graduate engineer trainee at a services company
  • Junior Java developer after a training bootcamp
  • Backend or integration roles with Spring in the stack
  • Banking and insurance technology teams that run on Java

Titles vary between companies; the evidence does not. A deployed project, a set of queries you can explain, or a case study with real testing behind it is what a fresher interview has to work with.

Frequently asked questions

Java or Python first?

If your target companies put Java on the paper โ€” the large services firms mostly do โ€” start with Java. Python is faster to become productive in; Java is faster to get hired into at a services company. Neither is wasted time: the loops, conditions and functions transfer.

Do I need to know data structures and algorithms first?

No. This course teaches the Java you need before DSA makes sense; the Interview DSA Crash Course is the natural next step, and it assumes you can write a loop and a class.

Is this course free?

Yes โ€” every module, example and practice task is free to read, and the tools on the Career Portal that go with it are free to use.

I never understood object-oriented programming in college. Will this fix it?

It is written for exactly that. Classes are introduced by building two of them, not by defining four pillars first. If you want to know how much of your gap is Java rather than interview skill, the free Career Pulse check scores both.

Not sure which of these you need first? The free Career Pulse check scores your skills, communication and goal clarity in about three minutes and tells you which gap to close first. Take the free check.