Java Tutorial
Learn Java from zero: syntax, OOP, collections, generics, streams, exceptions, multithreading, JDBC, JUnit and a first Spring Boot API.
- Topics
- 31
- Full lessons
- 31
- Est. hours
- ~6
- Interview Qs
- 10
Overview
Java is one of the most widely used programming languages, powering enterprise back ends, Android apps, big-data tools and countless services in banks and IT companies.
This track starts with the basics and moves through object-oriented programming, the collections framework, modern features such as lambdas, streams and records, then database access with JDBC, testing with JUnit and building a REST API with Spring Boot.
What you will learn
- Write Java programs with variables, control flow and methods
- Apply OOP with classes, interfaces and inheritance
- Use collections, generics, lambdas and streams
- Access databases with JDBC and build a Spring Boot REST API
Prerequisites
None — this track starts from the very beginning.
Learning path
The recommended sequence, from beginner to advanced. Each stage builds on the one before.
- 1Basics · 9 topics · BeginnerIntroduction to Java · Installing the JDK · Variables and Data Types · Operators · Conditional Statements · Loops · Methods · Arrays · Strings
- 2Object-Oriented Java · 7 topics · Beginner → IntermediateClasses and Objects · Constructors · Encapsulation · Inheritance · Polymorphism · Abstract Classes and Interfaces · Packages and Access Modifiers
- 3Core APIs · 8 topics · IntermediateException Handling · Collections Framework · Generics · Lambda Expressions · Streams API · Optional · File I/O · Date and Time API
- 4Advanced & Ecosystem · 6 topics · AdvancedMultithreading · Records and Sealed Classes · Maven and Gradle · JDBC · Unit Testing with JUnit · Spring Boot Basics
- 5Practice · 1 topics · AdvancedInterview Questions
Complete topic list
31 topicsBasics
9 topics- Introduction to JavaBeginner5m
- Installing the JDKBeginner5m
- Variables and Data TypesBeginner5m
- OperatorsBeginner5m
- Conditional StatementsBeginner5m
- LoopsBeginner5m
- MethodsBeginner5m
- ArraysBeginner5m
- StringsBeginner5m
Object-Oriented Java
7 topics- Classes and ObjectsBeginner5m
- ConstructorsBeginner5m
- EncapsulationBeginner5m
- InheritanceBeginner5m
- PolymorphismBeginner5m
- Abstract Classes and InterfacesIntermediate5m
- Packages and Access ModifiersIntermediate5m
Core APIs
8 topics- Exception HandlingIntermediate5m
- Collections FrameworkIntermediate5m
- GenericsIntermediate5m
- Lambda ExpressionsIntermediate5m
- Streams APIIntermediate5m
- OptionalIntermediate5m
- File I/OIntermediate5m
- Date and Time APIIntermediate5m
Advanced & Ecosystem
6 topics- MultithreadingAdvanced5m
- Records and Sealed ClassesAdvanced5m
- Maven and GradleAdvanced5m
- JDBCAdvanced5m
- Unit Testing with JUnitAdvanced5m
- Spring Boot BasicsAdvanced5m
Practice
1 topics- Interview QuestionsAdvanced15m
Code example
A taste of the track, from Introduction to Java.
public class Hello {
public static void main(String[] args) {
String name = "Techie Babaji";
System.out.println("Namaste from Java, " + name + "!");
}
}
// Compile and run:
// javac Hello.java → creates Hello.class (bytecode)
// java Hello → the JVM runs it
// Java 11+ can also run a single file directly: java Hello.java
Namaste from Java, Techie Babaji!
Practice exercises
Change the program to print your name and city on two lines.
Use jshell to calculate how many seconds are in a day.
Declare variables for a product: name, price, quantity and inStock, then print them.
Check whether a number n is even using %.
Return "Weekend" for SAT/SUN and "Weekday" otherwise with a switch expression.
Print the multiplication table of 7 from 1 to 10.
Show all 30 exercises
Write a method isAdult(int age) that returns true for 18 or above.
Find the highest mark in the array.
Count the vowels in a string.
Add a withdraw(double amount) method that only withdraws if the balance is enough.
Add a constructor Product(String name) with a default price of 1.0.
Make an Employee class whose salary can only increase via giveRaise(percent).
Create a CurrentAccount that overrides monthlyFee() to return 100.
Add a WalletPayment that returns "Paid from wallet".
Create an EmailNotifier that implements Notifier and prints "Email to …".
Which access modifier lets only classes in the same package use a method?
Parse "abc" with Integer.parseInt and print "Invalid number" instead of crashing.
Count how many times each word appears in a list.
Write a generic method swap that swaps two elements of a List<T>.
Sort a list of names by length, then alphabetically.
Get the names of the top 2 most expensive orders.
Return the uppercase name of customer 1 or "GUEST".
Append a line to log.txt, creating the file if needed.
Find the date 45 days after today.
Run two async lookups and combine their results with CompletableFuture.
Create a record Student(String name, int marks) that rejects marks above 100.
Which Maven command runs only the tests?
Insert a product with a PreparedStatement.
Add a test that an unknown coupon gives no discount.
Add GET /api/products/{id} that returns 404 when not found.
Common interview questions
- What are the JDK, JRE and JVM?
- What is the difference between == and equals()?
- Why are Strings immutable in Java?
- What is the difference between an abstract class and an interface?
- Checked vs unchecked exceptions?
- ArrayList vs LinkedList vs HashMap?
- What is the Streams API?
- What is Optional and how should it be used?
- How do you make code thread-safe?
- How does a Spring Boot REST controller work?