๐Ÿ“Š 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 1Java from zero1 of 53 lessons

Weeks 1โ€“2 โ€” the toolchain, types and text. Slow on purpose: everything later is built on these three weeks.

  1. Your first class and the main method

    Everything in Java lives inside a class, and a program starts at public static void main(String[] args). The words look strange because they are precise, not decorative.

    The lesson

    A Java program is a class with a main method, and the JVM runs that method last โ€” everything you write is called from somewhere, and main is where the calling starts. public static void main(String[] args) is a mouthful you can type for a week until it becomes automatic.

    Compile with javac Hello.java, which produces Hello.class, then run java Hello โ€” compile once, run anywhere the JVM exists. That two-step is the reason Java ended up in banks and service companies, and it is the first thing an interviewer asks a fresher to describe.

    The mistakes are a file name that does not match the public class name, and a forgotten semicolon at the end of a statement. Both produce messages that name the line and the file, so read the first error rather than the tenth โ€” one mistake in Java often produces a cascade.

    Java
    public class Hello {
        public static void main(String[] args) {
            System.out.println("Hello, Asha");
        }
    }
    
    // The file name MUST match the public class: Hello.java
    // Compile: javac Hello.java      Run: java Hello

    Example A file named Hello.java containing public class Hello with a main method prints one line; rename the file without renaming the class and it will not compile. Java enforces the rule that the public class and the filename agree.

    Practice Write, compile with javac and run with java โ€” not in an IDE โ€” and then send the same program a command-line argument and print it back.

  2. Types, variables and casting

    Java is statically typed: every variable has a type fixed at compile time. That is why Java programs fail at compile time instead of at 3am, and why interviews start with types.

    The lesson

    Java is statically typed: you declare the type and it does not change. int, long, double, boolean, char and String cover fresher work โ€” note that String starts with a capital, because it is a class and the others are primitives. Declaring the type is what stops a whole class of bugs before they compile.

    Narrowing needs an explicit cast and loses information: (int) 9.8 gives 9, and integer division is why 7 / 2 is 3. Widening is automatic and safe. If you need exact money arithmetic, neither is good enough โ€” use BigDecimal, which is what a service-company interviewer is checking when they ask about double.

    The mistakes are comparing strings with == instead of .equals() โ€” == compares references, which happen to match inside the string pool and fail on text from a file โ€” and reading a number as a String from Scanner and then doing arithmetic on it. Integer.parseInt() is the bridge.

    Java
    int     age    = 21;         // whole number
    double  marks  = 88.5;       // decimal
    boolean placed = false;
    char    grade  = 'A';
    String  name   = "Asha";     // a class, not a primitive
    
    int rounded = (int) marks;            // narrowing CAST drops the decimals
    String text = Integer.toString(age);
    int back    = Integer.parseInt(text); // text -> number

    Example int a = 7; int b = 2; a / b is 3, not 3.5 โ€” integer division truncates. Write (double) a / b and it becomes 3.5. Knowing this one line separates candidates who have run Java from candidates who have read about it.

    Practice Write a small calculator that takes the four operations and prints results as decimals, then check the division case carefully.

  3. Strings and StringBuilder

    A String is immutable: every "change" builds a new object. That single fact is behind half the Java questions in a fresher interview.

    The lesson

    A String in Java is immutable: every method that appears to change it returns a NEW string. That makes strings safe to pass around and it also means concatenating inside a loop builds a new string each round, which is how a fresher program becomes slow on a real file.

    Use StringBuilder when you are assembling text in a loop โ€” .append() then .toString() โ€” and the built-in String methods the rest of the time: length, charAt, substring, indexOf, split, replace, trim, toUpperCase, and String.format or %s for output. equalsIgnoreCase is what you want for comparing user input.

    The mistake is == for string comparison, and the second is string concatenation inside a loop over ten thousand rows. Both are common enough that interviewers ask about them by name, so learn the reason rather than the rule.

    Java
    String s = "Hello";
    System.out.println(s.length());          // 5
    System.out.println(s.toUpperCase());     // HELLO
    System.out.println(s.substring(1, 3));   // el
    System.out.println(s.contains("ell"));   // true
    
    // Building many Strings in a loop? StringBuilder avoids the copies.
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 3; i++) sb.append(i).append("-");
    System.out.println(sb.toString());

    Example Concatenating in a loop of 10000 rows creates 10000 discarded Strings; StringBuilder appends into one buffer and is the version to use. equals() compares content, == compares references โ€” a distinction that shows up in every written test.

    Practice Reverse a sentence, count the words and replace one word โ€” first with String methods, then with StringBuilder, and note the difference in readability.

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.