Java – 100+ Lab Exercises (Basic, Intermediate, Advanced)

🔰 Basic Level (30+ Exercises)

 

Goal: Build a strong foundation in Java programming, control structures, and object-oriented concepts.

 

Java Fundamentals

  • Set up Java SDK and IDE (Eclipse/IntelliJ).

  • Write your first Java program – “Hello World”.

  • Variables and Data Types – create a student info system.

  • Type casting and type conversion examples.

  • Arithmetic operations and precedence.

Control Structures & Loops

  • Even/Odd Number Checker using if/else.

  • Switch-case grade evaluator.

  • Multiplication table using for loop.

  • Prime number checker using while.

  • Pattern printing using nested loops (pyramids, diamonds).

Arrays & Strings

  • Reverse an array.

  • Search and sort arrays.

  • Palindrome checker using strings.

  • Count vowels, consonants in a string.

  • Anagram checker.

Object-Oriented Programming

  • Create a Car class with fields and methods.

  • Constructor overloading.

  • Inheritance example: Animal → Dog.

  • Method overriding.

  • Abstraction with abstract classes.


 

🚀 Intermediate Level (40+ Exercises)

 

Goal: Advance your Java knowledge with design patterns, data handling, collections, and multithreading.

 

Advanced OOP

  • Interface implementation – Shape interface.

  • Polymorphism using base and derived classes.

  • Use this and super keywords.

  • Singleton pattern implementation.

  • Use final, static, enum.

Exception Handling

  • Try-catch-finally example.

  • Custom exception creation and handling.

  • Multiple exception handling.

Collections & Generics

  • Create and sort a List of objects.

  • HashMap usage – phone directory.

  • Set operations – unique values.

  • Generic class and method implementation.

Multithreading

  • Extend Thread class and implement Runnable.

  • Thread synchronization example.

  • Producer-Consumer problem with wait/notify.

File I/O & Serialization

  • Read and write a text file.

  • Serialize and deserialize an object.

  • Directory traversal utility.


 

🧠 Advanced Level (40+ Exercises)

 

Goal: Integrate Java into full-stack development, advanced frameworks, and system-level programming.

 

JDBC & Database Connectivity

  • Connect Java with MySQL.

  • CRUD operations using JDBC.

  • PreparedStatement usage.

  • Transaction management.

Java Networking

  • Client-Server communication using Sockets.

  • Build a simple chat application.

  • URL and HttpURLConnection usage.

Java Collections Deep Dive

  • Implement a custom comparator.

  • PriorityQueue usage for task scheduling.

  • ConcurrentHashMap example.

  • LinkedList vs ArrayList benchmark.

Design Patterns

  • Factory pattern for object creation.

  • Observer pattern for event notification.

  • Decorator pattern to enhance functionality.

  • Strategy pattern for dynamic behavior change.

Web Development with Servlets & JSP

  • Setup Apache Tomcat and create a servlet.

  • Form handling using servlet + JSP.

  • Session tracking using HttpSession.

  • Servlet filter and listener implementation.

Spring Framework (Intro)

  • Spring Boot Hello World App.

  • RESTful API using Spring Boot.

  • Spring Data JPA with MySQL.

  • Spring Security login example.

 

Capstone Projects

 

  • Library Management System (Swing + JDBC)

  • Online Food Ordering App (Servlet + JSP + MySQL)

  • E-Commerce REST API (Spring Boot + JPA + JWT)

  • Chat Application (Socket Programming + Threads)

  • Banking System Simulation (OOP + Collections + I/O)


 

Tools & Environment

 

  • Languages: Java SE 8 / 11 / 17

  • Frameworks: Spring Boot, Hibernate

  • Databases: MySQL, PostgreSQL

  • IDEs: IntelliJ, Eclipse

  • Build Tools: Maven, Gradle

  • Testing: JUnit, Mockito

  • Version Control: Git & GitHub

Scroll to Top