๐Ÿ“Š 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 4The standard library, in depth4 of 53 lessons

Streams, sorting and dates: the parts of the Java library every fresher interview touches.

  1. Streams: loops that say what they mean

    A stream turns a loop into a pipeline: filter, map, sort, collect. It removes the index, the temporary list and the off-by-one, and it reads like the sentence describing the job.

    The lesson

    Streams are not automatically faster; their value is clarity. Keep them for short pipelines and go back to a loop when the body grows past a step or two.

    filter keeps some elements, map changes each one, collect gathers the result, forEach acts - those four cover most of what an interview asks.

    Java
    List<String> aNames = names.stream()
        .filter(n -> n.startsWith("A"))
        .map(String::toUpperCase)
        .sorted()
        .collect(Collectors.toList());
    
    int total = students.stream()
        .filter(s -> s.getMarks() >= 40)
        .mapToInt(Student::getMarks)
        .sum();

    Example names.stream().filter(n -> n.startsWith("A")).sorted().collect(Collectors.toList()) keeps the A-names, in order, in one expression.

    Practice Rewrite a loop over students as a stream that keeps the passed ones and prints their names, sorted.

  2. Comparable, Comparator and sorting

    Comparable makes a class know its own natural order; Comparator sorts by any rule you like, including several at once. Sorting objects by two fields is a routine task and a routine question.

    The lesson

    Use Comparable for the one obvious order of the type and Comparator for every other order, so callers choose rather than the class deciding.

    Comparator.comparing with method references removes the boilerplate compareTo body that used to make sorting look harder than it is.

    Java
    class Student implements Comparable<Student> {
        public int compareTo(Student o) { return Integer.compare(id, o.id); }
    }
    
    students.sort(Comparator.comparing(Student::getMarks)
                            .reversed()
                            .thenComparing(Student::getName));

    Example students.sort(Comparator.comparing(Student::getMarks).reversed().thenComparing(Student::getName)) sorts by marks descending, then by name.

    Practice Sort five students first by marks descending and then by name, using a Comparator chain.

  3. Dates, times and Optional

    Java's old Date class is a trap; java.time.LocalDate and LocalDateTime are the ones to use. Optional is the return type that says 'this might be missing' instead of returning null.

    The lesson

    LocalDate has a date and no time, LocalDateTime adds the time, ZonedDateTime adds the zone - pick the least you need and daylight-saving bugs disappear.

    Optional is for return values, not fields or parameters; used in the wrong place it makes code noisier than the null it replaced.

    Java
    LocalDate today = LocalDate.now();
    LocalDate due   = today.plusDays(7);
    long days       = ChronoUnit.DAYS.between(today, due);
    
    Optional<Student> s = repo.find(42);
    String name = s.map(Student::getName).orElse("unknown");

    Example LocalDate.now().plusDays(7) is a week from today; Optional.ofNullable(find(id)).orElseThrow() turns a missing value into a clear failure.

    Practice Compute a due date seven days from today, and write a method that returns an Optional instead of null.

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.