Java Coding Practice

core java assignments for practice

What kind of Java practice exercises are there?

How to solve these java coding challenges, why codegym is the best platform for your java code practice.

  • Tons of versatile Java coding tasks for learners with any background: from Java Syntax and Core Java topics to Multithreading and Java Collections
  • The support from the CodeGym team and the global community of learners (“Help” section, programming forum, and chat)
  • The modern tool for coding practice: with an automatic check of your solutions, hints on resolving the tasks, and advice on how to improve your coding style

core java assignments for practice

Click on any topic to practice Java online right away

Practice java code online with codegym.

In Java programming, commands are essential instructions that tell the computer what to do. These commands are written in a specific way so the computer can understand and execute them. Every program in Java is a set of commands. At the beginning of your Java programming practice , it’s good to know a few basic principles:

  • In Java, each command ends with a semicolon;
  • A command can't exist on its own: it’s a part of a method, and method is part of a class;
  • Method (procedure, function) is a sequence of commands. Methods define the behavior of an object.

Here is an example of the command:

The command System.out.println("Hello, World!"); tells the computer to display the text inside the quotation marks.

If you want to display a number and not text, then you do not need to put quotation marks. You can simply write the number. Or an arithmetic operation. For example:

Command to display the number 1.

A command in which two numbers are summed and their sum (10) is displayed.

As we discussed in the basic rules, a command cannot exist on its own in Java. It must be within a method, and a method must be within a class. Here is the simplest program that prints the string "Hello, World!".

We have a class called HelloWorld , a method called main() , and the command System.out.println("Hello, World!") . You may not understand everything in the code yet, but that's okay! You'll learn more about it later. The good news is that you can already write your first program with the knowledge you've gained.

Attention! You can add comments in your code. Comments in Java are lines of code that are ignored by the compiler, but you can mark with them your code to make it clear for you and other programmers.

Single-line comments start with two forward slashes (//) and end at the end of the line. In example above we have a comment //here we print the text out

You can read the theory on this topic here , here , and here . But try practicing first!

Explore the Java coding exercises for practicing with commands below. First, read the conditions, scroll down to the Solution box, and type your solution. Then, click Verify (above the Conditions box) to check the correctness of your program.

core java assignments for practice

The two main types in Java are String and int. We store strings/text in String, and integers (whole numbers) in int. We have already used strings and integers in previous examples without explicit declaration, by specifying them directly in the System.out.println() operator.

In the first case “I am a string” is a String in the second case 5 is an integer of type int. However, most often, in order to manipulate data, variables must be declared before being used in the program. To do this, you need to specify the type of the variable and its name. You can also set a variable to a specific value, or you can do this later. Example:

Here we declared a variable called a but didn't give it any value, declared a variable b and gave it the value 5 , declared a string called s and gave it the value Hello, World!

Attention! In Java, the = sign is not an equals sign, but an assignment operator. That is, the variable (you can imagine it as an empty box) is assigned the value that is on the right (you can imagine that this value was put in the empty box).

We created an integer variable named a with the first command and assigned it the value 5 with the second command.

Before moving on to practice, let's look at an example program where we will declare variables and assign values to them:

In the program, we first declared an int variable named a but did not immediately assign it a value. Then we declared an int variable named b and "put" the value 5 in it. Then we declared a string named s and assigned it the value "Hello, World!" After that, we assigned the value 2 to the variable a that we declared earlier, and then we printed the variable a, the sum of the variables a and b, and the variable s to the screen

This program will display the following:

We already know how to print to the console, but how do we read from it? For this, we use the Scanner class. To use Scanner, we first need to create an instance of the class. We can do this with the following code:

Once we have created an instance of Scanner, we can use the next() method to read input from the console or nextInt() if we should read an integer.

The following code reads a number from the console and prints it to the console:

Here we first import a library scanner, then ask a user to enter a number. Later we created a scanner to read the user's input and print the input out.

This code will print the following output in case of user’s input is 5:

More information about the topic you could read here , here , and here .

See the exercises on Types and keyboard input to practice Java coding:

Conditions and If statements in Java allow your program to make decisions. For example, you can use them to check if a user has entered a valid password, or to determine whether a number is even or odd. For this purpose, there’s an 'if/else statement' in Java.

The syntax for an if statement is as follows:

Here could be one or more conditions in if and zero or one condition in else.

Here's a simple example:

In this example, we check if the variable "age" is greater than or equal to 18. If it is, we print "You are an adult." If not, we print "You are a minor."

Here are some Java practice exercises to understand Conditions and If statements:

In Java, a "boolean" is a data type that can have one of two values: true or false. Here's a simple example:

The output of this program is here:

In addition to representing true or false values, booleans in Java can be combined using logical operators. Here, we introduce the logical AND (&&) and logical OR (||) operators.

  • && (AND) returns true if both operands are true. In our example, isBothFunAndEasy is true because Java is fun (isJavaFun is true) and coding is not easy (isCodingEasy is false).
  • || (OR) returns true if at least one operand is true. In our example, isEitherFunOrEasy is true because Java is fun (isJavaFun is true), even though coding is not easy (isCodingEasy is false).
  • The NOT operator (!) is unary, meaning it operates on a single boolean value. It negates the value, so !isCodingEasy is true because it reverses the false value of isCodingEasy.

So the output of this program is:

More information about the topic you could read here , and here .

Here are some Java exercises to practice booleans:

With loops, you can execute any command or a block of commands multiple times. The construction of the while loop is:

Loops are essential in programming to execute a block of code repeatedly. Java provides two commonly used loops: while and for.

1. while Loop: The while loop continues executing a block of code as long as a specified condition is true. Firstly, the condition is checked. While it’s true, the body of the loop (commands) is executed. If the condition is always true, the loop will repeat infinitely, and if the condition is false, the commands in a loop will never be executed.

In this example, the code inside the while loop will run repeatedly as long as count is less than or equal to 5.

2. for Loop: The for loop is used for iterating a specific number of times.

In this for loop, we initialize i to 1, specify the condition i <= 5, and increment i by 1 in each iteration. It will print "Count: 1" to "Count: 5."

Here are some Java coding challenges to practice the loops:

An array in Java is a data structure that allows you to store multiple values of the same type under a single variable name. It acts as a container for elements that can be accessed using an index.

What you should know about arrays in Java:

  • Indexing: Elements in an array are indexed, starting from 0. You can access elements by specifying their index in square brackets after the array name, like myArray[0] to access the first element.
  • Initialization: To use an array, you must declare and initialize it. You specify the array's type and its length. For example, to create an integer array that can hold five values: int[] myArray = new int[5];
  • Populating: After initialization, you can populate the array by assigning values to its elements. All elements should be of the same data type. For instance, myArray[0] = 10; myArray[1] = 20;.
  • Default Values: Arrays are initialized with default values. For objects, this is null, and for primitive types (int, double, boolean, etc.), it's typically 0, 0.0, or false.

In this example, we create an integer array, assign values to its elements, and access an element using indexing.

In Java, methods are like mini-programs within your main program. They are used to perform specific tasks, making your code more organized and manageable. Methods take a set of instructions and encapsulate them under a single name for easy reuse. Here's how you declare a method:

  • public is an access modifier that defines who can use the method. In this case, public means the method can be accessed from anywhere in your program.Read more about modifiers here .
  • static means the method belongs to the class itself, rather than an instance of the class. It's used for the main method, allowing it to run without creating an object.
  • void indicates that the method doesn't return any value. If it did, you would replace void with the data type of the returned value.

In this example, we have a main method (the entry point of the program) and a customMethod that we've defined. The main method calls customMethod, which prints a message. This illustrates how methods help organize and reuse code in Java, making it more efficient and readable.

In this example, we have a main method that calls the add method with two numbers (5 and 3). The add method calculates the sum and returns it. The result is then printed in the main method.

All composite types in Java consist of simpler ones, up until we end up with primitive types. An example of a primitive type is int, while String is a composite type that stores its data as a table of characters (primitive type char). Here are some examples of primitive types in Java:

  • int: Used for storing whole numbers (integers). Example: int age = 25;
  • double: Used for storing numbers with a decimal point. Example: double price = 19.99;
  • char: Used for storing single characters. Example: char grade = 'A';
  • boolean: Used for storing true or false values. Example: boolean isJavaFun = true;
  • String: Used for storing text (a sequence of characters). Example: String greeting = "Hello, World!";

Simple types are grouped into composite types, that are called classes. Example:

We declared a composite type Person and stored the data in a String (name) and int variable for an age of a person. Since composite types include many primitive types, they take up more memory than variables of the primitive types.

See the exercises for a coding practice in Java data types:

String is the most popular class in Java programs. Its objects are stored in a memory in a special way. The structure of this class is rather simple: there’s a character array (char array) inside, that stores all the characters of the string.

String class also has many helper classes to simplify working with strings in Java, and a lot of methods. Here’s what you can do while working with strings: compare them, search for substrings, and create new substrings.

Example of comparing strings using the equals() method.

Also you can check if a string contains a substring using the contains() method.

You can create a new substring from an existing string using the substring() method.

More information about the topic you could read here , here , here , here , and here .

Here are some Java programming exercises to practice the strings:

In Java, objects are instances of classes that you can create to represent and work with real-world entities or concepts. Here's how you can create objects:

First, you need to define a class that describes the properties and behaviors of your object. You can then create an object of that class using the new keyword like this:

It invokes the constructor of a class.If the constructor takes arguments, you can pass them within the parentheses. For example, to create an object of class Person with the name "Jane" and age 25, you would write:

Suppose you want to create a simple Person class with a name property and a sayHello method. Here's how you do it:

In this example, we defined a Person class with a name property and a sayHello method. We then created two Person objects (person1 and person2) and used them to represent individuals with different names.

Here are some coding challenges in Java object creation:

Static classes and methods in Java are used to create members that belong to the class itself, rather than to instances of the class. They can be accessed without creating an object of the class.

Static methods and classes are useful when you want to define utility methods or encapsulate related classes within a larger class without requiring an instance of the outer class. They are often used in various Java libraries and frameworks for organizing and providing utility functions.

You declare them with the static modifier.

Static Methods

A static method is a method that belongs to the class rather than any specific instance. You can call a static method using the class name, without creating an object of that class.

In this example, the add method is static. You can directly call it using Calculator.add(5, 3)

Static Classes

In Java, you can also have static nested classes, which are classes defined within another class and marked as static. These static nested classes can be accessed using the outer class's name.

In this example, Student is a static nested class within the School class. You can access it using School.Student.

More information about the topic you could read here , here , here , and here .

See below the exercises on Static classes and methods in our Java coding practice for beginners:

Java Tutorial

Java methods, java classes, java file handling, java how to's, java reference, java examples, java exercises.

You can test your Java skills with W3Schools' Exercises.

We have gathered a variety of Java exercises (with answers) for each Java Chapter.

Try to solve an exercise by editing some code, or show the answer to see what you've done wrong.

Count Your Score

You will get 1 point for each correct answer. Your score and total score will always be displayed.

Start Java Exercises

Start Java Exercises ❯

If you don't know Java, we suggest that you read our Java Tutorial from scratch.

Kickstart your career

Get certified by completing the course

Get Certified

COLOR PICKER

colorpicker

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]

Top Tutorials

Top references, top examples, get certified.

50 Java Projects with Source Code for All Skill Levels

Faraz Logo

By Faraz - July 20, 2024

50 Java projects with complete source code, suitable for beginners to experts. Dive into practical coding with these hands-on examples.

Explore 50 Java Projects with Source Code for All Skill Levels.jpg

Java , being one of the most popular programming languages globally, offers a vast array of opportunities for enthusiasts to practice and enhance their coding skills. Engaging in practical projects is one of the most effective ways to master Java programming. Here, we'll explore 50 Java projects with source code across different levels of complexity, suitable for beginners, intermediates, and advanced learners.

Table of Contents

Introduction to Java Projects

Java projects provide hands-on experience and are instrumental in reinforcing theoretical concepts. They offer a practical understanding of Java's syntax , structure, and functionality. Moreover, working on projects enables developers to tackle real-world problems, fostering creativity and problem-solving skills.

1. Calculator

50 Java Projects - Calculator

AuthorHouari ZEGAI
TechnologiesJava
Source Code

Houari ZEGAI's Calculator project offers a great opportunity for beginners to delve into Java programming. This simple yet effective project helps learners understand fundamental concepts like variables, operators, and basic user input/output. With clear, commented code, ZEGAI's Calculator is a fantastic starting point for those new to Java development . By studying and tinkering with this project, beginners can grasp core principles while gaining confidence in their coding abilities.

2. Guess the Number Game

50 Java Projects - Guess the Number Game

AuthorFaraz
TechnologiesJava
Source Code

The "Guess the Number" game is a classic Java project suitable for programmers of all skill levels. This interactive game challenges players to guess a randomly generated number within a specified range. With simple yet engaging gameplay, the "Guess the Number" project provides an excellent opportunity for beginners to practice essential Java concepts while having fun.

3. Currency Converter

50 Java Projects - Currency Converter

AuthorNaeem Rashid
TechnologiesJava
Source Code

The Currency Converter project is a practical and useful Java application that allows users to convert between different currencies. This project is suitable for programmers at various skill levels, providing an opportunity to apply Java programming concepts in a real-world scenario.

In the Currency Converter project, users input an amount in one currency and select the currency they wish to convert it to. The application then retrieves the latest exchange rates from a reliable source, such as an API, and performs the conversion calculation. By implementing this functionality, learners can gain valuable experience working with APIs, handling user input, and performing mathematical operations in Java.

4. Digital Clock

50 Java Projects - Digital Clock

AuthorDanish Khan
TechnologiesJava
Source Code

The Digital Clock project is a straightforward yet engaging Java application that displays the current time in a digital format. This project is suitable for beginners and intermediate programmers alike, offering an opportunity to practice essential Java concepts while creating a useful utility.

In the Digital Clock project, programmers utilize Java's date and time functionality to retrieve the current system time and display it on the screen. By incorporating graphical user interface (GUI) components such as labels and timers, learners can create an interactive clock display that updates in real-time. This hands-on approach allows beginners to familiarize themselves with GUI programming concepts while practicing core Java skills.

5. ToDo App

50 Java Projects - todo app

AuthorIsis Add-ons
TechnologiesJava
Source Code

The ToDo App project is a practical Java application that helps users organize their tasks and manage their daily activities efficiently. This project is suitable for programmers looking to develop their Java skills while creating a useful productivity tool.

In the ToDo App project, users can add tasks to a list, mark them as completed, and remove them as needed. By implementing features such as user input handling, task manipulation, and list management, learners gain valuable experience in Java programming fundamentals. Additionally, this project provides an opportunity to explore concepts like data structures, file handling, and user interface design.

6. QRCodeFX

50 Java Projects - QRCodeFX

AuthorHouari Zegai
TechnologiesJavaFX
Source Code

QRCodeFX is an exciting Java project that allows programmers to generate QR codes dynamically. This project leverages JavaFX, a powerful library for building graphical user interfaces, to create an interactive application for generating and displaying QR codes.

7. Weather Forecast App

50 Java Projects - Weather Forecast App

AuthorPanagiotis Drakatos
TechnologiesJava and Swing
Source Code

The Weather Forecast App project is an exciting Java application that provides users with up-to-date weather information for their location and other selected areas. This project combines Java programming with APIs to create a dynamic and user-friendly weather forecasting tool.

In the Weather Forecast App, users can input their location or select a specific city to view current weather conditions, including temperature, humidity, wind speed, and more. By integrating with a weather API, such as OpenWeatherMap, programmers can retrieve real-time weather data and display it in a clear and visually appealing format.

8. Temperature Converter Tool

50 Java Projects - Temperature Converter Tool

AuthorNikhil Deep
TechnologiesJava
Source Code

The Temperature Converter Tool is a handy Java application that allows users to convert temperatures between different units, such as Celsius, Fahrenheit, and Kelvin. This project provides a practical opportunity for programmers to develop their Java skills while creating a useful utility for everyday use.

In the Temperature Converter Tool, users can input a temperature value along with the unit of measurement (e.g., Celsius, Fahrenheit, or Kelvin) and select the desired output unit. The application then performs the conversion calculation and displays the result, allowing users to quickly and easily convert temperatures with precision.

9. Word Counter Tool

50 Java Projects - Word Counter Tool

AuthorSaurav Kumar
TechnologiesJavaFX
Source Code

The Word Counter Tool is a versatile Java application designed to analyze text and provide valuable insights into word frequency and usage. This project offers programmers a practical opportunity to hone their Java skills while creating a useful utility for text analysis.

In the Word Counter Tool, users can input a block of text or upload a text file, and the application will analyze the content to determine the frequency of each word. By utilizing Java's string manipulation capabilities and data structures such as maps or arrays, programmers can efficiently process the text and generate a comprehensive word count report.

10. Scientific Calculator

50 Java Projects - Scientific Calculator

AuthorVaishnavi Lugade
TechnologiesJava Swing
Source Code

The Scientific Calculator project is an advanced Java application that provides users with a wide range of mathematical functions and operations beyond basic arithmetic. This project is ideal for programmers looking to expand their Java skills while creating a powerful utility for scientific calculations.

In the Scientific Calculator, users can input mathematical expressions, including functions such as trigonometric, logarithmic, and exponential functions, and the application will evaluate and display the result accurately. By leveraging Java's math libraries and implementing parsing algorithms, programmers can create a robust calculator capable of handling complex mathematical computations with precision.

11. Tic Tac Toe

50 Java Projects - Tic Tac Toe

AuthorHouari Zegai
TechnologiesJava (Swing)
Source Code

The Tic Tac Toe project is a classic Java game that provides users with an opportunity to engage in a fun and strategic multiplayer experience. This project is perfect for programmers looking to apply their Java skills while creating an interactive game with simple rules and dynamic gameplay.

In the Tic Tac Toe game, two players take turns marking spaces on a 3x3 grid with their respective symbols (typically X and O), aiming to form a horizontal, vertical, or diagonal line of their symbols before their opponent. By implementing logic to handle user input, validate moves, and check for win conditions, programmers can create a fully functional and enjoyable game experience.

12. Drag and Drop Application

50 Java Projects - Drag and Drop Application

The Drag and Drop Application is a dynamic Java project that enables users to interact with graphical elements by dragging and dropping them across the application's interface. This project provides programmers with an opportunity to explore Java's graphical user interface (GUI) capabilities while creating an intuitive and interactive user experience.

13. Snake Game

50 Java Projects - Snake Game

AuthorJan Bodnar
TechnologiesJava and Swing
Source Code

The Snake Game project is a classic Java game that provides users with an entertaining and addictive gaming experience. This project offers programmers an opportunity to apply their Java skills while creating a dynamic and interactive game with simple yet challenging gameplay mechanics.

In the Snake Game, players control a snake that moves around a grid, consuming food items to grow longer while avoiding collisions with the walls of the grid or the snake's own body. By implementing logic to handle player input, update the snake's position, and detect collisions, programmers can create a compelling and immersive gaming experience.

14. Resume Builder

50 Java Projects - Resume Builder

AuthorMohd Shahbaz
TechnologiesJava Swing
Source Code

The Resume Builder project is a practical Java application designed to assist users in creating professional resumes efficiently. This project offers programmers an opportunity to apply their Java skills while developing a useful tool for individuals seeking to showcase their qualifications and experiences effectively.

15. Student Management System

50 Java Projects - Student Management System

AuthorBitto Kazi
TechnologiesJava
Source Code

The Student Management System project is a comprehensive Java application designed to streamline administrative tasks related to student information and academic records. This project offers programmers an opportunity to apply their Java skills while developing a robust and efficient system for managing student data.

In the Student Management System, administrators can perform various tasks such as adding new students, updating existing records, managing course enrollments, and generating reports. By implementing features such as database integration, user authentication, and data validation, programmers can create a reliable and user-friendly platform for organizing and accessing student information.

16. Rock Paper Scissors

50 Java Projects - Rock Paper Scissors

AuthorDarsh Jain
TechnologiesJava
Source Code

The Rock Paper Scissors project is a classic Java game that provides users with a simple yet entertaining gaming experience. This project offers programmers an opportunity to practice their Java skills while creating a fun and interactive game of chance.

In the Rock Paper Scissors game, players compete against the computer by selecting one of three options: rock, paper, or scissors. The winner is determined based on the rules of the game: rock beats scissors, scissors beats paper, and paper beats rock. By implementing logic to handle player input, generate random computer choices, and determine the outcome of each round, programmers can create an engaging gaming experience.

17. Hangman Game

50 Java Projects - Hangman Game

Authormkole
TechnologiesJava
Source Code

The Hangman Game project is a classic Java game that provides users with a challenging and engaging word-guessing experience. This project offers programmers an opportunity to practice their Java skills while creating a fun and interactive game of wit and strategy.

In the Hangman Game, players attempt to guess a secret word by suggesting letters one at a time. For each incorrect guess, a part of a hangman figure is drawn. The game continues until the player correctly guesses the word or the hangman figure is completed. By implementing logic to handle player input, manage the game state, and select random words, programmers can create an immersive gaming experience.

50 Java Projects - WebCam

AuthorHouari Zegai
TechnologiesJava
Source Code

The Webcam Application project is a Java application designed to interface with a webcam device and capture video or images. This project offers programmers an opportunity to apply their Java skills while creating a versatile tool for webcam usage.

19. Attendance Management System

50 Java Projects - Attendance Management System

AuthorAnum Ramzan
TechnologiesJava and SQL Server
Source Code

The Attendance Management System project is a comprehensive Java application designed to streamline attendance tracking and management processes in educational institutions or workplaces. This project offers programmers an opportunity to apply their Java skills while developing a robust and efficient system for managing attendance records.

In the Attendance Management System, administrators can perform various tasks such as recording attendance, generating attendance reports, managing leave requests, and tracking attendance trends over time. By implementing features such as user authentication, data encryption, and access control, programmers can create a secure and reliable platform for monitoring attendance data.

20. Chess Game

50 Java Projects - Chess Game

Author-
TechnologiesJava Swing UI
Source Code

The Chess Game project is a Java application that offers users a classic and strategic gaming experience. This project provides programmers with an opportunity to apply their Java skills while creating a sophisticated and engaging game of chess.

In the Chess Game, players take turns moving their pieces across an 8x8 grid, aiming to capture their opponent's pieces and ultimately checkmate their opponent's king. By implementing logic to handle player input, validate moves, and simulate game states, programmers can create a challenging and immersive gaming experience.

21. Vehicle Rental Management System

50 Java Projects - Vehicle Rental Management System

AuthorMalaka Madushan
TechnologiesJava
Source Code

The Vehicle Rental Management System is a comprehensive Java application designed to streamline the process of managing vehicle rentals for rental agencies or businesses. This project offers programmers an opportunity to apply their Java skills while developing a robust and efficient system for handling rental operations.

In the Vehicle Rental Management System, administrators can perform various tasks such as adding new vehicles to the inventory, managing rental reservations, tracking rental durations and payments, and generating reports. By implementing features such as database integration, user authentication, and data validation, programmers can create a reliable and user-friendly platform for managing vehicle rentals.

22. Quiz App

50 Java Projects - Quiz

AuthorHouari Zegai
TechnologiesJava and MySQL
Source Code

The Quiz App project is a Java application designed to provide users with an interactive and educational quiz experience. This project offers programmers an opportunity to apply their Java skills while creating a dynamic and engaging platform for quiz-taking.

In the Quiz App, users can choose from a variety of quiz topics or categories, such as science, history, literature, or general knowledge. The application presents users with multiple-choice questions related to the selected topic and provides instant feedback on their answers. By implementing logic to handle user input, track scores, and display quiz results, programmers can create an immersive and rewarding quiz experience.

23. Voting Management System

50 Java Projects - Voting Management System

AuthorNiraj Ranjan
TechnologiesJava Swing and Postgres
Source Code

The Voting Management System is a sophisticated Java application designed to facilitate the management of voting processes in elections or organizational decision-making. This project offers programmers an opportunity to apply their Java skills while developing a secure and efficient system for managing voting operations.

In the Voting Management System, administrators can oversee various aspects of the voting process, including voter registration, ballot creation, voter authentication, vote counting, and result reporting. By implementing features such as user authentication, encryption algorithms, and audit trails, programmers can create a robust and tamper-resistant platform for conducting fair and transparent elections.

24. Electricity Billing System

50 Java Projects - Electricity Billing System

AuthorAdarsh Verma
TechnologiesJava Swing and MySQL
Source Code

The Electricity Billing System is a Java application designed to automate and streamline the process of managing electricity bills for customers. This project offers programmers an opportunity to apply their Java skills while developing an efficient and user-friendly system for billing and invoicing.

In the Electricity Billing System, administrators can perform various tasks such as adding new customers, recording meter readings, calculating electricity consumption, generating bills, and processing payments. By implementing features such as database integration, billing algorithms, and user interfaces, programmers can create a reliable and accurate platform for managing electricity billing operations.

25. Online Shopping Cart (E-Commerce Website)

50 Java Projects - Online Shopping Cart E-Commerce Website

AuthorShashi Raj
TechnologiesJava, Servlet, and MySQL
Source Code

The Online Shopping Cart project is a comprehensive Java application designed to provide users with a seamless and convenient online shopping experience. This project offers programmers an opportunity to apply their Java skills while developing a feature-rich and user-friendly e-commerce platform.

In the Online Shopping Cart, users can browse through a catalog of products, add items to their cart, and proceed to checkout to complete their purchase. By implementing features such as user authentication, product search functionality, shopping cart management, and secure payment processing, programmers can create a robust and reliable platform for online shopping.

26. Online BookStore

50 Java Projects - Online BookStore

AuthorShashi Raj
TechnologiesJava
Source Code

The Online Bookstore project is a dynamic Java application that provides users with a convenient platform to browse, search, and purchase books online. This project offers programmers an opportunity to apply their Java skills while developing a comprehensive and user-friendly e-commerce platform specifically tailored for books.

In the Online Bookstore, users can explore a vast catalog of books across different genres, authors, and topics. They can easily search for specific titles, view book details, read reviews, and add books to their shopping cart for purchase. By implementing features such as user authentication, secure payment processing, and order management, programmers can create a seamless and enjoyable shopping experience for book enthusiasts.

27. Connect4

50 Java Projects - Connect4

The Connect4 Game project is a Java application that offers users a classic and engaging gaming experience. This project provides programmers with an opportunity to apply their Java skills while developing a strategic and entertaining game of Connect 4.

In the Connect4 Game, two players take turns dropping colored discs into a vertical grid with the goal of connecting four discs of their color horizontally, vertically, or diagonally. By implementing logic to handle player input, validate moves, and detect winning conditions, programmers can create an immersive and challenging gaming experience.

28. Event Management System

50 Java Projects - Event Management System

AuthorAnkur Gangwar
TechnologiesJava AWT, Swing, and MySQL
Source Code

The Event Management System is a comprehensive Java application designed to streamline the planning and organization of events for various purposes, such as conferences, weddings, or corporate gatherings. This project offers programmers an opportunity to apply their Java skills while developing a versatile and efficient system for managing event logistics.

In the Event Management System, administrators can perform various tasks such as creating event schedules, managing guest lists, coordinating vendors and suppliers, and tracking expenses and budgets. By implementing features such as user authentication, calendar integration, and communication tools, programmers can create a centralized platform for planning and executing events seamlessly.

29. Puzzle Game

50 Java Projects - Puzzle Game

The Puzzle Game project is an engaging Java application that challenges users with a variety of mind-bending puzzles to solve. This project provides programmers with an opportunity to apply their Java skills while creating an entertaining and intellectually stimulating gaming experience.

In the Puzzle Game, players are presented with a series of puzzles, each requiring a unique solution or strategy to complete. These puzzles may include logic puzzles, pattern recognition challenges, maze navigation tasks, or spatial reasoning exercises. By implementing logic to generate puzzles, validate player inputs, and track progress, programmers can create a dynamic and immersive gaming experience.

30. Pacman Game

50 Java Projects - Pacman Game

AuthorJan Bodnar
TechnologiesJava
Source Code

The Pacman Game project is a classic Java application that brings to life the iconic arcade game experience. This project offers programmers an opportunity to apply their Java skills while recreating the nostalgic and beloved gameplay of Pacman.

In the Pacman Game, players control the iconic character Pacman as they navigate through a maze, eating pellets and avoiding ghosts. The objective is to clear the maze of all pellets while avoiding contact with the ghosts, which will result in losing a life. By implementing logic to handle player input, control Pacman's movement, and manage ghost behavior, programmers can recreate the thrilling and addictive gameplay of Pacman.

31. Space Invaders Game

50 Java Projects - Space Invaders Game

The Space Invaders Game project is a thrilling Java application that immerses players in an epic battle against invading alien forces. This project provides programmers with an opportunity to apply their Java skills while recreating the classic arcade gaming experience of Space Invaders.

In the Space Invaders Game, players control a spaceship at the bottom of the screen, tasked with defending Earth from waves of descending alien invaders. The player can move the spaceship horizontally to dodge enemy fire and shoot projectiles to eliminate the invading aliens. By implementing logic to handle player input, manage alien movement patterns, and detect collisions, programmers can recreate the fast-paced and addictive gameplay of Space Invaders.

32. Breakout Game

50 Java Projects - Breakout Game

The Breakout Game project is an exhilarating Java application that challenges players to smash through rows of bricks using a bouncing ball and a paddle. This project offers programmers an opportunity to apply their Java skills while recreating the timeless and addictive gameplay of Breakout.

In the Breakout Game, players control a paddle at the bottom of the screen, tasked with bouncing a ball to break through a wall of bricks at the top. The player must maneuver the paddle to keep the ball in play and prevent it from falling off the bottom of the screen. By implementing logic to handle player input, simulate ball movement and collision detection, and manage brick destruction, programmers can recreate the fast-paced and exciting gameplay of Breakout.

33. Tetris Game

50 Java Projects - Tetris Game

The Tetris Game project is an exciting Java application that challenges players to manipulate falling tetrominoes to create complete lines and clear the playing field. This project provides programmers with an opportunity to apply their Java skills while recreating the iconic and addictive gameplay of Tetris.

In the Tetris Game, players control the descent of tetrominoes—geometric shapes composed of four square blocks— as they fall from the top of the screen to the bottom. The player can rotate and maneuver the tetrominoes to fit them into gaps and create solid lines across the playing field. By implementing logic to handle player input, simulate tetromino movement and rotation, and detect line completions, programmers can recreate the fast-paced and challenging gameplay of Tetris.

34. Minesweeper Game

50 Java Projects - Minesweeper Game

The Minesweeper Game project is a captivating Java application that challenges players to uncover hidden mines on a grid-based playing field while avoiding detonating any of them. This project provides programmers with an opportunity to apply their Java skills while recreating the engaging and strategic gameplay of Minesweeper.

In the Minesweeper Game, players are presented with a grid of squares, some of which conceal hidden mines. The objective is to uncover all the non-mine squares without triggering any mines. Players can reveal the contents of a square by clicking on it, and clues provided by adjacent squares indicate the number of mines in proximity. By implementing logic to handle player input, reveal squares, and detect game-ending conditions, programmers can recreate the challenging and thought-provoking gameplay of Minesweeper.

50 Java Projects - ChatFx

AuthorHouari Zegai
TechnologiesJavaFX and Socket
Source Code

ChatFx is a Java-based chat application that provides users with a platform to engage in real-time text-based conversations. This project offers programmers an opportunity to apply their Java skills while developing a dynamic and interactive chat system.

36. Chrome Dino Game

50 Java Projects - Chrome Dino Game

AuthorNabhoneel Majumdar
TechnologiesJava
Source Code

The Chrome Dino Game Clone project is a Java application inspired by the classic side-scrolling endless runner game found in Google Chrome's offline page. This project offers programmers an opportunity to apply their Java skills while recreating the simple yet addictive gameplay of the Chrome Dino Game.

In the Chrome Dino Game Clone, players control a dinosaur character that automatically runs forward on a desert landscape. The objective is to jump over obstacles such as cacti and birds while avoiding collisions. By implementing logic to handle player input for jumping, detect collisions with obstacles, and generate random obstacle patterns, programmers can recreate the fast-paced and challenging gameplay of the Chrome Dino Game.

37. Web Scraping

50 Java Projects - Web Scrapping

AuthorHouari Zegai
TechnologiesJava and JSoup
Source Code

Web scraping refers to the process of extracting data from websites. It's a valuable technique for gathering information from the web for various purposes, such as data analysis, market research, or content aggregation. In Java, developers can leverage libraries like Jsoup to perform web scraping efficiently and effectively.

Jsoup is a Java library that provides a convenient API for working with HTML documents. With Jsoup, developers can easily parse HTML, navigate the document structure, and extract relevant data using CSS selectors or DOM traversal methods.

38. Text Editor

50 Java Projects - Text Editor

AuthorPH7 de Soria
TechnologiesJava
Source Code

A Text Editor is a fundamental tool used for creating, editing, and managing text-based documents. Building a Text Editor application in Java provides an excellent opportunity for programmers to apply their skills while creating a versatile and user-friendly tool for text manipulation.

In Java, developers can leverage libraries like JavaFX to create graphical user interfaces (GUIs) for their applications. JavaFX offers a rich set of features for building interactive and visually appealing desktop applications, making it well-suited for developing a Text Editor.

39. Tender Management System

50 Java Projects - Tender Management System

AuthorShashi Raj
TechnologiesJava, JSP, and MySQL
Source Code

A Tender Management System is a comprehensive software solution designed to streamline the process of tendering, from initial announcement to final contract award. This system facilitates the entire tender lifecycle, including tender creation, submission, evaluation, and contract management. Building a Tender Management System in Java presents an opportunity for developers to create a powerful tool that enhances efficiency and transparency in the tendering process.

40. Hotel Reservation System

50 Java Projects - Hotel Reservation System

AuthorHouari Zegai
TechnologiesJavaEE, MySQL, and Bootstrap
Source Code

A Hotel Reservation System is a software application designed to streamline the process of booking accommodations and managing reservations for hotels, resorts, or other lodging establishments. Building a Hotel Reservation System in Java provides developers with an opportunity to create a comprehensive solution that enhances the efficiency and customer experience of hotel management.

41. Train Ticket Reservation System

50 Java Projects - Train Ticket Reservation System

AuthorShashi Raj
TechnologiesJava, Servlet, and Oracle
Source Code

A Train Ticket Reservation System is a software application designed to facilitate the booking of train tickets and management of reservations for railway passengers. Building a Train Ticket Reservation System in Java provides developers with an opportunity to create a comprehensive solution that enhances the efficiency and convenience of train travel.

42. School Management System

50 Java Projects - School Management System

AuthorHouari Zegai
TechnologiesJavaFX, JFoenix, Jasper Reports, and MySQL
Source Code

A School Management System is a comprehensive software solution designed to streamline various administrative tasks within educational institutions. This system helps manage student information, class schedules, attendance records, grading, and communication between teachers, students, and parents. Building a School Management System in Java provides an efficient way to organize and automate processes, ultimately enhancing the effectiveness of school administration.

43. Banking System

50 Java Projects - Banking System

AuthorHendi Santika
TechnologiesJava, Springboot, Angular, and MySQL
Source Code

A Banking System is a software application used by financial institutions to manage customer accounts, transactions, and other banking operations. This system facilitates activities such as account management, fund transfers, loan processing, and online banking services. Building a Banking System in Java involves implementing secure and efficient algorithms for managing financial transactions, ensuring data integrity and confidentiality, and providing a seamless user experience for customers.

44. Restaurant Management System

50 Java Projects - Restaurant Management System

AuthorShahin Alam
TechnologiesJava
Source Code

A Restaurant Management System is a software platform used by restaurants and food service establishments to manage various aspects of their operations, including order management, inventory control, table reservations, and billing. This system helps streamline restaurant workflows, improve efficiency, and enhance the dining experience for customers. Building a Restaurant Management System in Java involves designing user-friendly interfaces, integrating with point-of-sale devices, and implementing features such as menu customization, order tracking, and kitchen management.

45. Library Management System

50 Java Projects - Library Management System

AuthorMuhammed Afsal Villan
TechnologiesJavaFX
Source Code

A Library Management System is a software application used by libraries to manage their collections, circulation, and patron services. This system helps librarians track books, manage borrower information, automate check-in and check-out processes, and generate reports on library usage. Building a Library Management System in Java involves designing a database schema to store book and patron information, implementing search and retrieval functionalities, and providing a user-friendly interface for library staff and patrons to interact with the system.

46. Mail Sender

50 Java Projects - Mail Sender

A Mail Sender is a software application used to compose, send, and manage emails. This tool facilitates communication by allowing users to send messages to one or more recipients over email. Building a Mail Sender in Java involves integrating with email protocols such as SMTP (Simple Mail Transfer Protocol) or using third-party email APIs to handle email delivery and management.

47. 2048 Game

50 Java Projects - 2048

The 2048 Game is a popular single-player puzzle game where players slide numbered tiles on a grid to combine them and create a tile with the number 2048. Building a 2048 Game in Java involves implementing game mechanics such as tile movement, tile merging, scoring, and game over conditions. Developers can use graphical libraries like JavaFX or Swing to create a user interface for the game.

48. Table Generator

50 Java Projects - Table Generator

AuthorHouari Zegai
TechnologiesJavaFX and JFoenix
Source Code

A Table Generator is a tool used to create tables or grids with specified dimensions and content. This tool is often used in document preparation, web development, or data analysis to generate structured data displays. Building a Table Generator in Java involves designing a user interface for users to input table parameters such as rows, columns, and content, and then generating the table output dynamically.

49. Health Care Management System

50 Java Projects - Health Care Management System

AuthorHeshan Eranga
TechnologiesJava
Source Code

A Health Care Management System is a software application used by healthcare providers to manage patient records, appointments, medical history, and other administrative tasks. This system helps streamline healthcare workflows, improve patient care, and enhance operational efficiency. Building a Health Care Management System in Java involves integrating with healthcare standards such as HL7 (Health Level Seven) for data exchange and implementing features such as patient registration, appointment scheduling, and electronic health record (EHR) management.

50. Energy Saving System

50 Java Projects - Energy Saving System

AuthorNaeem Rashid
TechnologiesJavFX
Source Code

An Energy Saving System is a software application used to monitor, analyze, and optimize energy usage in buildings, facilities, or industrial processes. This system helps identify energy inefficiencies, track energy consumption patterns, and implement strategies to reduce energy consumption and costs. Building an Energy Saving System in Java involves integrating with sensors, meters, and building management systems to collect energy data, performing data analysis to identify energy-saving opportunities, and implementing control algorithms to optimize energy usage in real-time.

Engaging in Java projects with source code is an invaluable aspect of learning and mastering the language. Whether you're a novice aiming to solidify your foundation or an experienced developer seeking to enhance your skills, embarking on practical projects offers a rewarding learning experience. By exploring projects across different levels of complexity, developers can broaden their understanding, tackle challenges, and unleash their creativity in the world of Java programming.

Q1. Where can I find Java projects with source code for beginners?

Beginners can find Java projects on platforms like GitHub, CodeProject, and tutorial websites catering specifically to novice programmers.

Q2. How do Java projects help in learning programming?

Java projects provide hands-on experience, reinforce theoretical concepts, and promote problem-solving skills crucial for mastering programming.

Q3. Are Java projects suitable for advanced developers?

Yes, advanced developers can benefit from Java projects by tackling complex problems, exploring new technologies, and contributing to open-source projects.

Q4. Can I modify existing Java projects to suit my requirements?

Absolutely! Modifying existing Java projects allows developers to customize functionality, experiment with different approaches, and enhance their coding skills.

Q5. Are there online communities for discussing Java projects and seeking help?

Yes, numerous online forums and programming communities exist where developers can share ideas, seek assistance, and collaborate on Java projects.

Creating a Youtube Sidebar with HTML, CSS, and JavaScript.jpg

That’s a wrap!

Thank you for taking the time to read this article! I hope you found it informative and enjoyable. If you did, please consider sharing it with your friends and followers. Your support helps me continue creating content like this.

Stay updated with our latest content by signing up for our email newsletter ! Be the first to know about new articles and exciting updates directly in your inbox. Don't miss out—subscribe today!

If you'd like to support my work directly, you can buy me a coffee . Your generosity is greatly appreciated and helps me keep bringing you high-quality articles.

Thanks! Faraz 😊

Subscribe to my Newsletter

Get the latest posts delivered right to your inbox, latest post.

Create Business Card Using HTML and CSS - Step-by-Step Guide

Create Business Card Using HTML and CSS - Step-by-Step Guide

Learn how to create a stylish business card using HTML and CSS. Follow our easy step-by-step guide to design and code your own business card in just a few minutes!

Create Dice Rolling Game using HTML, CSS, and JavaScript

Create Dice Rolling Game using HTML, CSS, and JavaScript

August 21, 2024

Create Janmashtami Dahi Handi Animation with HTML, CSS, and JavaScript

Create Janmashtami Dahi Handi Animation with HTML, CSS, and JavaScript

Create Indian Independence Day Flag Animation using HTML, CSS & GSAP

Create Indian Independence Day Flag Animation using HTML, CSS & GSAP

August 15, 2024

How to Write a Plan Expiry Alert Email with an HTML Template

How to Write a Plan Expiry Alert Email with an HTML Template

August 13, 2024

Create Animated Logout Button Using HTML and CSS

Create Animated Logout Button Using HTML and CSS

Learn to create an animated logout button using simple HTML and CSS. Follow step-by-step instructions to add smooth animations to your website’s logout button.

Create Fortnite Buttons Using HTML and CSS - Step-by-Step Guide

Create Fortnite Buttons Using HTML and CSS - Step-by-Step Guide

June 05, 2024

How to Create a Scroll Down Button: HTML, CSS, JavaScript Tutorial

How to Create a Scroll Down Button: HTML, CSS, JavaScript Tutorial

March 17, 2024

How to Create a Trending Animated Button Using HTML and CSS

How to Create a Trending Animated Button Using HTML and CSS

March 15, 2024

Create Interactive Booking Button with mask-image using HTML and CSS (Source Code)

Create Interactive Booking Button with mask-image using HTML and CSS (Source Code)

March 10, 2024

Learn how to create a dice rolling game using HTML, CSS, and JavaScript. Follow our easy-to-understand guide with clear instructions and code examples.

Create a Breakout Game with HTML, CSS, and JavaScript | Step-by-Step Guide

Create a Breakout Game with HTML, CSS, and JavaScript | Step-by-Step Guide

July 14, 2024

Create a Whack-a-Mole Game with HTML, CSS, and JavaScript | Step-by-Step Guide

Create a Whack-a-Mole Game with HTML, CSS, and JavaScript | Step-by-Step Guide

June 12, 2024

Create Your Own Bubble Shooter Game with HTML and JavaScript

Create Your Own Bubble Shooter Game with HTML and JavaScript

May 01, 2024

Build a Number Guessing Game using HTML, CSS, and JavaScript | Source Code

Build a Number Guessing Game using HTML, CSS, and JavaScript | Source Code

April 01, 2024

Tooltip Hover to Preview Image with Tailwind CSS

Tooltip Hover to Preview Image with Tailwind CSS

Learn how to create a tooltip hover effect to preview images using Tailwind CSS. Follow our simple steps to add this interactive feature to your website.

Create Image Color Extractor Tool using HTML, CSS, JavaScript, and Vibrant.js

Create Image Color Extractor Tool using HTML, CSS, JavaScript, and Vibrant.js

January 23, 2024

Build a Responsive Screen Distance Measure with HTML, CSS, and JavaScript

Build a Responsive Screen Distance Measure with HTML, CSS, and JavaScript

January 04, 2024

Crafting Custom Alarm and Clock Interfaces using HTML, CSS, and JavaScript

Crafting Custom Alarm and Clock Interfaces using HTML, CSS, and JavaScript

November 30, 2023

Detect User's Browser, Screen Resolution, OS, and More with JavaScript using UAParser.js Library

Detect User's Browser, Screen Resolution, OS, and More with JavaScript using UAParser.js Library

October 30, 2023

Creating a Responsive Footer with Tailwind CSS (Source Code)

Creating a Responsive Footer with Tailwind CSS (Source Code)

Learn how to design a modern footer for your website using Tailwind CSS with our detailed tutorial. Perfect for beginners in web development.

Crafting a Responsive HTML and CSS Footer (Source Code)

Crafting a Responsive HTML and CSS Footer (Source Code)

November 11, 2023

Create an Animated Footer with HTML and CSS (Source Code)

Create an Animated Footer with HTML and CSS (Source Code)

October 17, 2023

Bootstrap Footer Template for Every Website Style

Bootstrap Footer Template for Every Website Style

March 08, 2023

How to Create a Responsive Footer for Your Website with Bootstrap 5

How to Create a Responsive Footer for Your Website with Bootstrap 5

August 19, 2022

Welcome to Java! Easy Max Score: 3 Success Rate: 97.04%

Java stdin and stdout i easy java (basic) max score: 5 success rate: 96.83%, java if-else easy java (basic) max score: 10 success rate: 91.38%, java stdin and stdout ii easy java (basic) max score: 10 success rate: 92.79%, java output formatting easy java (basic) max score: 10 success rate: 96.54%, java loops i easy java (basic) max score: 10 success rate: 97.66%, java loops ii easy java (basic) max score: 10 success rate: 97.32%, java datatypes easy java (basic) max score: 10 success rate: 93.71%, java end-of-file easy java (basic) max score: 10 success rate: 97.91%, java static initializer block easy java (basic) max score: 10 success rate: 96.12%, cookie support is required to access hackerrank.

Seems like cookies are disabled on this browser, please enable them to open this website

Uploaded avatar of jmrunkle

Practice 147 exercises in Java

Learn and practice Java by completing 147 exercises that explore different concepts and ideas.

Explore the Java exercises on Exercism

Unlock more exercises as you progress. They’re great practice and fun to do!

Start training on this collection. Each time you skip or complete a kata you will be taken to the next kata in the series. Once you cycle through the items in the collection you will revert back to your normal training routine.

Description Edit

Get starting with your java coding practice with these java exercises. There is a wide range of java problems to solve.

Delete This Collection

Deleting the collection cannot be undone.

Collect: kata

Loading collection data...

You have not created any collections yet.

Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.

Get started now by creating a new collection .

Set the name for your new collection. Remember, this is going to be visible by everyone so think of something that others will understand.

Java Programming Exercises

  • All Exercises
  • Java 8 - Lambdas & Streams
  • Binary Tree

I created this website to help developers improve their programming skills by practising simple coding exercises. The target audience is Software Engineers, Test Automation Engineers, or anyone curious about computer programming. The primary programming language is Java, as it is mature and easy to learn, but you can practice the same problems in any other language (Kotlin, Python, Javascript, etc.).

  • Binary Tree problems are common at Google, Amazon and Facebook coding interviews.
  • Sharpen your lambda and streams skills with Java 8 coding practice problems .
  • Check our Berlin Clock solution , a commonly used code exercise.
  • We have videos too! Check out the FizzBuzz solution , a problem widely used on phone screenings.

How does it work ?

1. Choose difficulty

Easy, moderate or challenging.

2. Choose the exercise

From a list of coding exercises commonly found in interviews.

3. Type in your code

No IDE, no auto-correct... just like the whiteboard interview question.

4. Check results

Typically 3-5 unit tests that verify your code.

[email protected]

Email

  • C Program : Remove All Characters in String Except Alphabets
  • C Program : Sorting a String in Alphabetical Order – 2 Ways
  • C Program : Remove Vowels from A String | 2 Ways
  • C Program To Check Whether A Number Is Even Or Odd | C Programs
  • C Program To Check If Vowel Or Consonant | 4 Simple Ways
  • C Program To Count The Total Number Of Notes In A Amount | C Programs
  • C Program To Print Number Of Days In A Month | Java Tutoring
  • C Program To Input Any Alphabet And Check Whether It Is Vowel Or Consonant
  • C Program To Find Maximum Between Three Numbers | C Programs
  • C Program To Find Reverse Of An Array – C Programs
  • C Program To Check If Alphabet, Digit or Special Character | C Programs
  • C Program To Check Whether A Character Is Alphabet or Not
  • C Program To Check A Number Is Negative, Positive Or Zero | C Programs
  • C Program Inverted Pyramid Star Pattern | 4 Ways – C Programs
  • C Program To Check Character Is Uppercase or Lowercase | C Programs
  • C Program To Calculate Profit or Loss In 2 Ways | C Programs
  • C Program To Check Whether A Year Is Leap Year Or Not | C Programs
  • C Program Find Circumference Of A Circle | 3 Ways
  • C Program Area Of Triangle | C Programs
  • C Program To Check If Triangle Is Valid Or Not | C Programs
  • C Program To Check Number Is Divisible By 5 and 11 or Not | C Programs
  • C Program Hollow Diamond Star Pattern | C Programs
  • Mirrored Rhombus Star Pattern Program In c | Patterns
  • X Star Pattern C Program 3 Simple Ways | C Star Patterns
  • C Program Area Of Rectangle | C Programs
  • C Program To Find Area Of Semi Circle | C Programs
  • C Program Area Of Parallelogram | C Programs
  • C Program Area Of Rhombus – 4 Ways | C Programs
  • C Program Area Of Isosceles Triangle | C Programs
  • C Program Area Of Trapezium – 3 Ways | C Programs
  • C Program Area Of Square | C Programs
  • C Program To Find Volume of Sphere | C Programs
  • C Program Check A Character Is Upper Case Or Lower Case
  • C Program to find the Area Of a Circle
  • C Program Area Of Equilateral Triangle | C Programs
  • Hollow Rhombus Star Pattern Program In C | Patterns
  • C Program To Calculate Volume Of Cube | C Programs
  • C Program To Count Total Number Of Notes in Given Amount
  • C Program To Find Volume Of Cone | C Programs
  • C Program To Calculate Perimeter Of Rectangle | C Programs
  • C Program To Calculate Perimeter Of Rhombus | C Programs
  • C Program To Calculate Perimeter Of Square | C Programs
  • C Program Volume Of Cuboid | C Programs
  • C Program To Left Rotate An Array | C Programs
  • C Program Count Number Of Words In A String | 4 Ways
  • C Program To Search All Occurrences Of A Character In String | C Programs
  • C Program To Count Occurrences Of A Word In A Given String | C Programs
  • C Program To Remove First Occurrence Of A Character From String
  • C Program To Copy All Elements From An Array | C Programs
  • C Program To Delete Duplicate Elements From An Array | 4 Ways
  • C Program Volume Of Cylinder | C Programs
  • C Square Star Pattern Program – C Pattern Programs | C Programs
  • C Program To Delete An Element From An Array At Specified Position | C Programs
  • C Program To Compare Two Strings – 3 Easy Ways | C Programs
  • C Program To Toggle Case Of Character Of A String | C Programs
  • C Program To Find Reverse Of A string | 4 Ways
  • C Mirrored Right Triangle Star Pattern Program – Pattern Programs
  • C Program To Search All Occurrences Of A Word In String | C Programs
  • Hollow Square Pattern Program in C | C Programs
  • C Program To Trim Leading & Trailing White Space Characters From String
  • C Programs – 500+ Simple & Basic Programming Examples & Outputs
  • C Program To Reverse Words In A String | C Programs
  • C Program Inverted Right Triangle Star Pattern – Pattern Programs
  • C Plus Star Pattern Program – Pattern Programs | C
  • Rhombus Star Pattern Program In C | 4 Multiple Ways
  • C Program Replace All Occurrences Of A Character With Another In String
  • C Program To Find Maximum & Minimum Element In Array | C Prorams
  • C Pyramid Star Pattern Program – Pattern Programs | C
  • C Program To Remove Repeated Characters From String | 4 Ways
  • C Program To Count Frequency Of Each Character In String | C Programs
  • C Program To Remove Blank Spaces From String | C Programs
  • C Program To Remove Last Occurrence Of A Character From String
  • C Program Right Triangle Star Pattern | Pattern Programs
  • C Program To Find Last Occurrence Of A Word In A String | C Programs
  • C Program To Count Number Of Even & Odd Elements In Array | C Programs
  • C Program To Copy One String To Another String | 4 Simple Ways
  • C Program To Find Last Occurrence Of A Character In A Given String
  • C Program Replace First Occurrence Of A Character With Another String
  • C Program Number Of Alphabets, Digits & Special Character In String | Programs
  • C Program To Search An Element In An Array | C Programs
  • C Program To Check A String Is Palindrome Or Not | C Programs
  • Merge Two Arrays To Third Array C Program | 4 Ways
  • C Program To Trim White Space Characters From String | C Programs
  • C Program To Print Number Of Days In A Month | 5 Ways
  • C Program To Concatenate Two Strings | 4 Simple Ways
  • C Program To Find First Occurrence Of A Word In String | C Programs
  • C Program To Sort Even And Odd Elements Of Array | C Programs
  • C Program Count Number Of Vowels & Consonants In A String | 4 Ways
  • C Program To Sort Array Elements In Ascending Order | 4 Ways
  • C Program To Remove First Occurrence Of A Word From String | 4 Ways
  • Highest Frequency Character In A String C Program | 4 Ways
  • C Program To Trim Trailing White Space Characters From String | C Programs
  • C Program To Count Frequency Of Each Element In Array | C Programs
  • C Program To Count Occurrences Of A Character In String | C Programs
  • C Program To Convert Uppercase String To Lowercase | 4 Ways
  • C Program To Convert Lowercase String To Uppercase | 4 Ways
  • C Program To Put Even And Odd Elements Of Array Into Two Separate Arrays
  • C Program To Print All Unique Elements In The Array | C Programs
  • C Program Find Maximum Between Two Numbers | C Programs
  • C Program Hollow Inverted Mirrored Right Triangle
  • C Program Hollow Inverted Right Triangle Star Pattern
  • Diamond Star Pattern C Program – 4 Ways | C Patterns
  • C Program To Sort Array Elements In Descending Order | 3 Ways
  • C Program Count Number of Duplicate Elements in An Array | C Programs
  • C Program To Find Sum Of All Array Elements | 4 Simple Ways
  • C Program To Replace Last Occurrence Of A Character In String | C Programs
  • C Program To Remove All Occurrences Of A Character From String | C Programs
  • C Program To Insert Element In An Array At Specified Position
  • C Program To Input Week Number And Print Week Day | 2 Ways
  • C Program Hollow Mirrored Rhombus Star Pattern | C Programs
  • C Program To Find Lowest Frequency Character In A String | C Programs
  • C Program Hollow Mirrored Right Triangle Star Pattern
  • C Program To Read & Print Elements Of Array | C Programs
  • C Program To Count Number Of Negative Elements In Array
  • C Program To Right Rotate An Array | 4 Ways
  • C Program To Find First Occurrence Of A Character In A String
  • C Program Half Diamond Star Pattern | C Pattern Programs
  • 8 Star Pattern – C Program | 4 Multiple Ways
  • Hollow Inverted Pyramid Star Pattern Program in C
  • Right Arrow Star Pattern Program In C | 4 Ways
  • C Program To Print All Negative Elements In An Array
  • C Program To Find Length Of A String | 4 Simple Ways
  • C Program : Capitalize First & Last Letter of A String | C Programs
  • C Program : Check if Two Strings Are Anagram or Not
  • C Program : Check if Two Arrays Are the Same or Not | C Programs
  • C Program Hollow Right Triangle Star Pattern
  • Left Arrow Star Pattern Program in C | C Programs
  • C Program Inverted Mirrored Right Triangle Star Pattern
  • Hollow Pyramid Star Pattern Program in C
  • C Program Mirrored Half Diamond Star Pattern | C Patterns
  • C Program : Non – Repeating Characters in A String | C Programs
  • C Program : Sum of Positive Square Elements in An Array | C Programs
  • C Program : Find Longest Palindrome in An Array | C Programs
  • C Program Lower Triangular Matrix or Not | C Programs
  • C Program : To Reverse the Elements of An Array | C Programs
  • C Program Merge Two Sorted Arrays – 3 Ways | C Programs
  • C Program : Convert An Array Into a Zig-Zag Fashion
  • C Program : Maximum Scalar Product of Two Vectors
  • C Program : Check If Arrays are Disjoint or Not | C Programs
  • C Program : Minimum Scalar Product of Two Vectors | C Programs
  • C Program : Find Missing Elements of a Range – 2 Ways | C Programs
  • C Program Transpose of a Matrix 2 Ways | C Programs
  • C program : Find Median of Two Sorted Arrays | C Programs
  • C Program : To Find Maximum Element in A Row | C Programs
  • C Program : Rotate the Matrix by K Times | C Porgrams
  • C Program Patterns of 0(1+)0 in The Given String | C Programs
  • C Program : Check if An Array Is a Subset of Another Array
  • C Program : To Find the Maximum Element in a Column
  • C Program To Check Upper Triangular Matrix or Not | C Programs
  • C Program : Rotate a Given Matrix by 90 Degrees Anticlockwise
  • C Program : Non-Repeating Elements of An Array | C Programs
  • C Program Sum of Each Row and Column of A Matrix | C Programs

Learn Java Java Tutoring is a resource blog on java focused mostly on beginners to learn Java in the simplest way without much effort you can access unlimited programs, interview questions, examples

Java programs – 500+ simple & basic programs with outputs.

in Java Programs , Java Tutorials July 19, 2024 Comments Off on Java Programs – 500+ Simple & Basic Programs With Outputs

Java programs: Basic Java programs with examples & outputs. Here we covered over the list of 500+ Java simple programs for beginners to advance, practice & understood how java programming works. You can take a pdf of each program along with source codes & outputs.

In case if you are looking out for C Programs , you can check out that link.

We covered major Simple to basic Java Programs along with sample solutions for each method. If you need any custom program you can contact us.

All of our Sample Java programs with outputs in pdf format are written by expert authors who had high command on Java programming. Even our Java Tutorials are with rich in-depth content so that newcomers can easily understand.

1. EXECUTION OF A JAVA PROGRAM   

Static loading :  A block of code would be loaded into the RAM before it executed ( i.e after being loaded into the RAM it may or may not get executed )

Dynamic loading:   A block of code would be loaded into the RAM only when it is required to be executed.

Note:   Static loading took place in the execution of structured programming languages. EX:  c- language

Java  follows the Dynamic loading

–     JVM would not convert all the statements of the class file into its executable code at a time.

–     Once the control comes out from the method, then it is deleted from the RAM and another method of exe type will be loaded as required.

–     Once the control comes out from the main ( ), the main ( ) method would also be deleted from the RAM. This is why we are not able to view the exe contents of a class file.

Simple Hello Word Program

Out of 500+ Simple & Basic Java Programs: Hello world is a first-ever program which we published on our site. Of course, Every Java programmer or C programmer will start with a “Hello World Program”. Followed by the rest of the programs in different Categories.

HelloWorld public static void main(String args[]) { System.out.println("Hello World"); }

Basic Java Programs – Complete List Here

Advanced simple programming examples with sample outputs, string, array programs.

Sort Programs

Conversion Programs:

Star & Number Pattern Programs

Functions of JVM:

  • It converts the required part if the bytecode into its equivalent executable code.
  • It loads the executable code into the RAM.
  • Executes this code through the local operating system.
  • Deletes the executable code from the RAM.

We know that JVM converts the class file into its equivalent executable code. Now if a JVM is in windows environment executable code that is understood by windows environment only.

Similarly, same in the case with UNIX or other or thus JVM ID platform dependent.

Java, With the help of this course, students can now get a confidant to write a basic program to in-depth algorithms in C Programming or Java Programming to understand the basics one must visit the list 500 Java programs to get an idea.

Users can now download the top 100 Basic Java programming examples in a pdf format to practice.

But the platform dependency of the JVM is not considered while saying Java is platform independent because JVM is supplied free of cost through the internet by the sun microsystems.

Platform independence :

Compiled code of a program should be executed in any operating system, irrespective of the as in OS in which that code had been generated. This concept is known as platform independence.

  • The birth of oops concept took place with encapsulation.
  • Any program contains two parts.
  • Date part and Logic part
  • Out of data and logic the highest priority we have given to data.
  • But in a structured programming language, the data insecurity is high.
  • Thus in a process, if securing data in structured prog. lang. the concept of encapsulation came into existence.
Note: In structured programming lang programs, the global variable play a vital role.

But because of these global variables, there is data insecurity in the structured programming lang programs. i.e functions that are not related to some variables will have access to those variables and thus data may get corrupted. In this way data is unsecured.

“This is what people say in general about data insecurity. But this is not the actual reason. The actual concept is as follows”.

Let us assume that, we have a ‘C’ program with a hundred functions. Assume that it is a project. Now if any upgradation is required, then the client i.e the user of this program (s/w) comes to its company and asks the programmers to update it according to his requirement.

Now we should note that it is not guaranteed that the programmers who developed this program will still be working with that company. Hence this project falls into the hands of new programmers.

Automatically it takes a lot of time to study. The project itself before upgrading it. It may not be surprising that the time required for writing the code to upgrade the project may be very less when compared to the time required for studying the project.

Thus maintenance becomes a problem.

If the new programmer adds a new function to the existing code in the way of upgrading it, there is no guarantee that it will not affect the existing functions in the code. This is because of global variables. In this way, data insecurity is created.

  • To overcome this problem, programmers developed the concept of encapsulation .
  • For example, let us have a struc.prog.lang. program with ten global variables and twenty functions.
  • It is sure that all the twenty functions will not use all the global variables .

Three of the global variables may be used only by two functions. But in a structured prog. Lang like ‘C’ it is not possible to restrict the access of global variables by some limited no of functions.

Every function will have access to all the global variables.

To avoid this problem, programmers have designed a way such that the variables and the functions which are associated with or operate on those variables are enclosed in a block and that bock is called a class and that class and that class is given a name, Just as a function is given a name.

Now the variables inside the block cannot be called as the local variable because they cannot be called as global variables because they are confined to a block and not global.

Hence these variables are known as instance variables

. Prog. Lang. program include < stdio.h> i,j,k,l,m,n; 1 ( ) --- 2 ---- 10 ( ) ---- ( ) ----

_______________________________________________________________

Example 2 :

. Lang program Abc   i,j,k 1 ( ) --- Xyz   l,m,n; 3 ( ) --- 4 ( ) ---

Therefore a class is nothing but grouping data along with its functionalities.

Note 1:  E ncapsulation it’s the concept of binding data along with its corresponding functionalities.

Encapsulations came into existence in order to provide security for the data present inside the program.

Note 2: Any object oriental programming language file looks like a group of classes. Everything is encapsulated. Nothing is outside the class.

  • Encapsulation is the backbone of oop languages.
  • JAVA supports all the oop concepts ( i.e. encapsulation, polymorphism, inheritance) and hence it is known as an object-oriented programming language.
  • C++ breaks the concept of encapsulation because the main ( ) method in a  C++ program is declared outside a class. Hence it is not a pure oop language, in fact, it is a poor oop language.

Related Posts !

core java assignments for practice

VPN Blocked by Java Security on PC? Here’s How to Fix That

August 23, 2024

core java assignments for practice

HCF Of Two & N Numbers Java Program | 3 Ways

August 21, 2024

LCM Of Two Numbers Java Program | 5 Ways – Programs

August 18, 2024

Java Program Convert Fahrenheit To Celsius | Vice Versa

August 14, 2024

Java Program Count Vowels In A String | Programs

August 12, 2024

X Star Pattern Java Program – Patterns

August 8, 2024

core java assignments for practice

Square Star Pattern Program In Java – Patterns

Java program to print square star pattern program. We have written the below print/draw square ...

Javatpoint Logo

Java Tutorial

Control statements, java object class, java inheritance, java polymorphism, java abstraction, java encapsulation, java oops misc.

JavaTpoint

Java is a popular programming language that is used to develop a wide variety of applications. One of the best ways to learn Java is to practice writing programs. Many resources are available online and in libraries to help you find Java practice programs.

When practising Java programs, it is important to focus on understanding the concepts behind the code. Don't just copy and paste code from a website or book. Try to understand why the code is written the way it is. It will help you become a better Java programmer.





Youtube

  • Send your Feedback to [email protected]

Help Others, Please Share

facebook

Learn Latest Tutorials

Splunk tutorial

Transact-SQL

Tumblr tutorial

Reinforcement Learning

R Programming tutorial

R Programming

RxJS tutorial

React Native

Python Design Patterns

Python Design Patterns

Python Pillow tutorial

Python Pillow

Python Turtle tutorial

Python Turtle

Keras tutorial

Preparation

Aptitude

Verbal Ability

Interview Questions

Interview Questions

Company Interview Questions

Company Questions

Trending Technologies

Artificial Intelligence

Artificial Intelligence

AWS Tutorial

Cloud Computing

Hadoop tutorial

Data Science

Angular 7 Tutorial

Machine Learning

DevOps Tutorial

B.Tech / MCA

DBMS tutorial

Data Structures

DAA tutorial

Operating System

Computer Network tutorial

Computer Network

Compiler Design tutorial

Compiler Design

Computer Organization and Architecture

Computer Organization

Discrete Mathematics Tutorial

Discrete Mathematics

Ethical Hacking

Ethical Hacking

Computer Graphics Tutorial

Computer Graphics

Software Engineering

Software Engineering

html tutorial

Web Technology

Cyber Security tutorial

Cyber Security

Automata Tutorial

C Programming

C++ tutorial

Control System

Data Mining Tutorial

Data Mining

Data Warehouse Tutorial

Data Warehouse

RSS Feed

  • Data Science
  • Courses 2 Offers Active

Featured Sprints

Guru99

Java Tutorial for Beginners: Learn Core Java Programming

James Hartman

Java Tutorial Summary

This Java tutorial for beginners is taught in a practical GOAL-oriented way. It is recommended you practice the code assignments given after each core Java tutorial to learn Java from scratch. This Java programming for beginners course will help you learn basics of Java and advanced concepts.

What is Java?

Java is a class-based object-oriented programming language for building web and desktop applications. It is the most popular programming language and the language of choice for Android programming.

Java Syllabus

First Steps in Java Basics

👉 — An introduction, Definition & Features of Java Platforms
👉 — What is Java Virtual Machine & its Architecture
👉 — How to Download & Install Java JDK 8 in Windows
👉 — How to Download & Install Eclipse to Run Java
👉 — How to Download & Install Java in Linux(Ubuntu)
👉 — How to print in Java with Examples: 3 Methods
👉 — Hello World: How to Create Your First Java Program

Basics Concepts of Object-Oriented Programming (OOPs)

👉 — Learn OOPs Basics with Examples
👉 — What is Java Abstract Class & Method
👉 — Learn with an Example

Java Basics Language Constructs

👉 — What is & Data Types with Example
👉 — Learn with Example
👉 — Declare, Create, Initialize with Example
👉 — How to Create Array of Objects in Java
👉 — How to Use, Methods & Examples

Learn Java String Tutorial

👉 — Java String Manipulation: Functions and Methods
👉 — Learn with Example
👉 — Learn with Example
👉 — Learn with Example
👉 — How to Use with Examples
👉 — Check Substring with Example
👉 — Learn with Example
👉 — Learn with Example
👉 — Learn with Example
👉 — How to convert & Example
👉 — How to compare two Strings in Java (11 Methods)
👉 — What is Hashmap? Features & Example

Most Misunderstood Topics!

👉 — Learn with Example
👉 — What is & How to use with Example

Java Memory Management

👉 — What is, How it Works, Example
👉 — Java Static Method, Variable & Block
👉 — Java Stack and Heap Memory Allocation
  • Java String toLowercase() and toUpperCase() Methods
  • Program to Print Prime Number From 1 to 100 in Java
  • How to Open a JAR File in Windows, Online

Abstract Class & Interface in Java

👉 — Inheritance in Java OOPs with Example
👉 — Polymorphism in Java OOPs with Example
👉 — What is, Abstract Class & Method
👉 — What is Interface in Java with Example
👉 — Know the Difference

Better Late than Never

👉 — What is Constructor in Java? Program Examples
👉 — What is, How to Create/Import Package in Java

Exception Handling in Java

👉 — What is Exception in Java? Examples
👉 — How to Create User Defined Exception in Java
👉 — Throws Keyword in Java with Example

Conditional Loops in Java

👉 — Enhanced for Loop to Iterate Java Array
👉 — Learn Java Switch-Case Statement with Example

Java Advance Stuff!

👉 — Java Math Abs() Round() Ceil() Floor() Min() Methods
👉 — How to Generate Random Number in Java
👉 — SimpleDateFormat, Current Date & Compare
👉 — Learn with Examples
👉 — Method, block, static type
👉 — How to Create a GUI in Java with Examples
👉 — How to Split String with Example
👉 — How to Read File in Java with Example
👉 — Java Reflection API Tutorial with Example
👉 — Learn Groovy Script Step by Step for Beginners
👉 — What is Spring Framework & How to Install
👉 — What is Apache Ant Build Tool?
👉 — What is, How to Install, Report Example
👉 — Kotlin Programming [Code example]
👉 — Scala Programming Language Example & Code

Java Programs

👉 — Check whether number is prime or not
👉 — Convert using Gson and JAXB: JAVA Example
👉 — How to display prime numbers using Java
👉 — How to Convert Char to String in Java (Examples)
👉 — Fibonacci Series Program in Java using Loops & Recursion
👉 — Java Program to Check Armstrong Number
👉 — How to Reverse a String in Java using Recursion
👉 — Check number is Palindrome or Not
👉 — How to Print Star, Pyramid, Number
👉 — Sorting Algorithm Example
👉 — Insertion Sort Algorithm in Java Program with Example
👉 — Java Program for Selection Sorting with Example

Java Differences

👉 — What’s the Difference?
👉 — Key Differences
👉 — 10 Key Differences between Java and C#
👉 — What’s the Difference?
👉 — What is the Difference?
👉 — Key Differences
👉 — What’s the Difference?

Java Interview Questions, Tools & Books

👉 — Top 100 Java Interview Questions & Answers
👉 — 35+ Java 8 Interview Questions and Answers
👉 — Top 80 Most Frequently Asked
👉 — Top 22 Most Frequently Asked
👉 — Top 25 Most Frequently Asked
👉 — Top 22 Most Frequently Asked
👉 — Top 25 Most Frequently Asked
👉 — List of Top 20 Java Tools for Developers
👉 — List of Top 15 BEST Java IDE
👉 — 15 Best Java Programming Books for Beginner
👉 — Download Java Programming Tutorial for Beginners PDF

What will you learn in this Java Tutorial for Beginners?

In this Java tutorial for beginners, you will learn Java programming basics like What is Java platform, JVM, how to install Java, OOPS concepts, variables, class, object, arrays, strings, command-line arguments, garbage collection, inheritance, polymorphism, interface, constructor, packages, etc. You will also learn advanced concepts like switch-case, functions, multithreading, swing, files, API, Java Spring, etc., in this Java basics for beginners guide.

Prerequisites for learning Java Tutorial?

This free Java for beginners tutorial is designed for beginners with little or no Java coding experience. These Java notes for beginners will help beginners to learn Java online for free.

Why Learn Java Programming?

Here are the reasons why you should learn Java:

  • Java is very easy to learn.
  • Java developers are in demand, and it easy to get a job as a Java programmer.
  • It has a good collection of open-source libraries.
  • Java is free.

What are the Benefits of Java?

Here are the benefits of Java:

  • Java is object-oriented.
  • It is platform-independent.
  • You can effortlessly write, compile, and debug programs compare to other programming languages.

Applications of Java Programming

Following are the major applications of Java Programming language:

  • Mobile Applications
  • Web Applications
  • Web and Application servers
  • Enterprise Applications
  • Embedded Applications
  • Desktop GUI Applications

What are the types of Java programs?

Here are the types of Java Program:

  • Stand-alone applications.
  • Web Applications using JSP , Servlet, Spring, Hibernate, JSF, etc.

How do I get real-time exposure to Java?

You can get real-time exposure to Java by coding in live projects. You can join our Live Java Project to get your hands dirty in Java.

  • ▼Java Exercises
  • ▼Java Basics
  • Basic Part-I
  • Basic Part-II
  • ▼Java Data Types
  • Java Enum Types
  • ▼Java Control Flow
  • Conditional Statement
  • Recursive Methods
  • ▼Java Math and Numbers
  • ▼Object Oriented Programming
  • Java Constructor
  • Java Static Members
  • Java Nested Classes
  • Java Inheritance
  • Java Abstract Classes
  • Java Interface
  • Java Encapsulation
  • Java Polymorphism
  • Object-Oriented Programming
  • ▼Exception Handling
  • Exception Handling Home
  • ▼Functional Programming
  • Java Lambda expression
  • ▼Multithreading
  • Java Thread
  • Java Multithreading
  • ▼Data Structures
  • ▼Strings and I/O
  • File Input-Output
  • ▼Date and Time
  • ▼Advanced Concepts
  • Java Generic Method
  • ▼Algorithms
  • ▼Regular Expressions
  • Regular Expression Home
  • ▼JavaFx Exercises
  • JavaFx Exercises Home
  • ..More to come..

Java Array: Exercises, Practice, Solution

Java array exercises [79 exercises with solution].

[ An editor is available at the bottom of the page to write and execute the scripts.   Go to the editor ]

1. Write a Java program to sort a numeric array and a string array.

Click me to see the solution

2. Write a Java program to sum values of an array.

3. Write a Java program to print the following grid.

Expected Output :

4. Write a Java program to calculate the average value of array elements.

5. Write a Java program to test if an array contains a specific value.

6. Write a Java program to find the index of an array element.

7. Write a Java program to remove a specific element from an array.

8. Write a Java program to copy an array by iterating the array.

9. Write a Java program to insert an element (specific position) into an array.

10. Write a Java program to find the maximum and minimum value of an array.

11. Write a Java program to reverse an array of integer values.

12. Write a Java program to find duplicate values in an array of integer values.

13. Write a Java program to find duplicate values in an array of string values.

14. Write a Java program to find common elements between two arrays (string values).

15. Write a Java program to find common elements between two integer arrays.

16. Write a Java program to remove duplicate elements from an array.

17. Write a Java program to find the second largest element in an array.

18. Write a Java program to find the second smallest element in an array.

19. Write a Java program to add two matrices of the same size.

20. Write a Java program to convert an array to an ArrayList.

21. Write a Java program to convert an ArrayList to an array.

22. Write a Java program to find all pairs of elements in an array whose sum is equal to a specified number.

23. Write a Java program to test two arrays' equality.

24. Write a Java program to find a missing number in an array.

25. Write a Java program to find common elements in three sorted (in non-decreasing order) arrays.

26. Write a Java program to move all 0's to the end of an array. Maintain the relative order of the other (non-zero) array elements.

27. Write a Java program to find the number of even and odd integers in a given array of integers.

28. Write a Java program to get the difference between the largest and smallest values in an array of integers. The array must have a length of at least 1.

29. Write a Java program to compute the average value of an array of integers except the largest and smallest values.

30. Write a Java program to check if an array of integers is without 0 and -1.

31. Write a Java program to check if the sum of all the 10's in the array is exactly 30. Return false if the condition does not satisfy, otherwise true.

32. Write a Java program to check if an array of integers contains two specified elements 65 and 77.

33. Write a Java program to remove duplicate elements from a given array and return the updated array length. Sample array: [20, 20, 30, 40, 50, 50, 50] After removing the duplicate elements the program should return 4 as the new length of the array. 

34. Write a Java program to find the length of the longest consecutive elements sequence from an unsorted array of integers. Sample array: [49, 1, 3, 200, 2, 4, 70, 5] The longest consecutive elements sequence is [1, 2, 3, 4, 5], therefore the program will return its length 5. 

35. Write a Java program to find the sum of the two elements of a given array equal to a given integer. Sample array: [1,2,4,5,6] Target value: 6. 

36. Write a Java program to find all the distinct triplets such that the sum of all the three elements [x, y, z (x ≤ y ≤ z)] equal to a specified number. Sample array: [1, -2, 0, 5, -1, -4] Target value: 2. 

37. Write a Java program to create an array of its anti-diagonals from a given square matrix. 

Example: Input : 1 2 3 4 Output: [ [1], [2, 3], [4] ]

38. Write a Java program to get the majority element from an array of integers containing duplicates.  

Majority element: A majority element is an element that appears more than n/2 times where n is the array size.

39. Write a Java program to print all the LEADERS in the array.   Note: An element is leader if it is greater than all the elements to its right side.

40. Write a Java program to find the two elements in a given array of positive and negative numbers such that their sum is close to zero.  

41. Write a Java program to find the smallest and second smallest elements of a given array.  

42. Write a Java program to separate 0s and 1s in an array of 0s and 1s into left and right sides.  

43. Write a Java program to find all combinations of four elements of an array whose sum is equal to a given value.  

44. Write a Java program to count the number of possible triangles from a given unsorted array of positive integers.   Note: The triangle inequality states that the sum of the lengths of any two sides of a triangle must be greater than or equal to the length of the third side.

45. Write a Java program to cyclically rotate a given array clockwise by one.  

46. Write a Java program to check whether there is a pair with a specified sum in a given sorted and rotated array.  

47. Write a Java program to find the rotation count in a given rotated sorted array of integers.  

48. Write a Java program to arrange the elements of an array of integers so that all negative integers appear before all positive integers.  

49. Write a Java program to arrange the elements of an array of integers so that all positive integers appear before all negative integers.  

50. Write a Java program to sort an array of positive integers from an array. In the sorted array the value of the first element should be maximum, the second value should be a minimum, third should be the second maximum, the fourth should be the second minimum and so on.  

51. Write a Java program that separates 0s on the left hand side and 1s on the right hand side from a random array of 0s and 1.  

52. Write a Java program to separate even and odd numbers from a given array of integers. Put all even numbers first, and then odd numbers.  

53. Write a Java program to replace every element with the next greatest element (from the right side) in a given array of integers. There is no element next to the last element, therefore replace it with -1. 

54. Write a Java program to check if a given array contains a subarray with 0 sum.  

Example: Input : nums1= { 1, 2, -2, 3, 4, 5, 6 } nums2 = { 1, 2, 3, 4, 5, 6 } nums3 = { 1, 2, -3, 4, 5, 6 } Output: Does the said array contain a subarray with 0 sum: true Does the said array contain a subarray with 0 sum: false Does the said array contain a subarray with 0 sum: true

55. Write a Java program to print all sub-arrays with 0 sum present in a given array of integers.  

Example: Input : nums1 = { 1, 3, -7, 3, 2, 3, 1, -3, -2, -2 } nums2 = { 1, 2, -3, 4, 5, 6 } nums3= { 1, 2, -2, 3, 4, 5, 6 } Output: Sub-arrays with 0 sum : [1, 3, -7, 3] Sub-arrays with 0 sum : [3, -7, 3, 2, 3, 1, -3, -2] Sub-arrays with 0 sum : [1, 2, -3] Sub-arrays with 0 sum : [2, -2]

56. Write a Java program to sort a binary array in linear time.   From Wikipedia, Linear time: An algorithm is said to take linear time, or O(n) time, if its time complexity is O(n). Informally, this means that the running time increases at most linearly with the size of the input. More precisely, this means that there is a constant c such that the running time is at most cn for every input of size n. For example, a procedure that adds up all elements of a list requires time proportional to the length of the list, if the adding time is constant, or, at least, bounded by a constant. Linear time is the best possible time complexity in situations where the algorithm has to sequentially read its entire input. Therefore, much research has been invested into discovering algorithms exhibiting linear time or, at least, nearly linear time. This research includes both software and hardware methods. There are several hardware technologies which exploit parallelism to provide this. An example is content-addressable memory. This concept of linear time is used in string matching algorithms such as the Boyer–Moore algorithm and Ukkonen's algorithm.

Example: Input : b_nums[] = { 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 } Output: After sorting: [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]

57. Write a Java program to check if a sub-array is formed by consecutive integers from a given array of integers.  

Example: Input : nums = { 2, 5, 0, 2, 1, 4, 3, 6, 1, 0 } Output: The largest sub-array is [1, 7] Elements of the sub-array: 5 0 2 1 4 3 6

58. Given two sorted arrays A and B of size p and q, write a Java program to merge elements of A with B by maintaining the sorted order i.e. fill A with first p smallest elements and fill B with remaining elements.  

Example: Input : int[] A = { 1, 5, 6, 7, 8, 10 } int[] B = { 2, 4, 9 } Output: Sorted Arrays: A: [1, 2, 4, 5, 6, 7] B: [8, 9, 10]

59. Write a Java program to find the maximum product of two integers in a given array of integers.  

Example: Input : nums = { 2, 3, 5, 7, -7, 5, 8, -5 } Output: Pair is (7, 8), Maximum Product: 56

60. Write a Java program to shuffle a given array of integers.  

Example: Input : nums = { 1, 2, 3, 4, 5, 6 } Output: Shuffle Array: [4, 2, 6, 5, 1, 3]

61. Write a Java program to rearrange a given array of unique elements such that every second element of the array is greater than its left and right elements.  

Example: Input : nums= { 1, 2, 4, 9, 5, 3, 8, 7, 10, 12, 14 } Output: Array with every second element is greater than its left and right elements: [1, 4, 2, 9, 3, 8, 5, 10, 7, 14, 12]

62. Write a Java program to find equilibrium indices in a given array of integers.  

Example: Input : nums = {-7, 1, 5, 2, -4, 3, 0} Output: Equilibrium indices found at : 3 Equilibrium indices found at : 6

63. Write a Java program to replace each element of the array with the product of every other element in a given array of integers.  

Example: Input : nums1 = { 1, 2, 3, 4, 5, 6, 7} nums2 = {0, 1, 2, 3, 4, 5, 6, 7} Output: Array with product of every other element: [5040, 2520, 1680, 1260, 1008, 840, 720] Array with product of every other element: [5040, 0, 0, 0, 0, 0, 0, 0]

64. Write a Java program to find the Longest Bitonic Subarray in a given array.  

A bitonic subarray is a subarray of a given array where elements are first sorted in increasing order, then in decreasing order. A strictly increasing or strictly decreasing subarray is also accepted as bitonic subarray.

Example: Input : nums = { 4, 5, 9, 5, 6, 10, 11, 9, 6, 4, 5 } Output: The longest bitonic subarray is [3,9] Elements of the said sub-array: 5 6 10 11 9 6 4 The length of longest bitonic subarray is 7

65. Write a Java program to find the maximum difference between two elements in a given array of integers such that the smaller element appears before the larger element.  

Example: Input : nums = { 2, 3, 1, 7, 9, 5, 11, 3, 5 } Output: The maximum difference between two elements of the said array elements 10

66. Write a Java program to find a contiguous subarray within a given array of integers with the largest sum.  

In computer science, the maximum sum subarray problem is the task of finding a contiguous subarray with the largest sum, within a given one-dimensional array A[1...n] of numbers. Formally, the task is to find indices and with, such that the sum is as large as possible.

Example: Input : int[] A = {1, 2, -3, -4, 0, 6, 7, 8, 9} Output: The largest sum of contiguous sub-array: 30

67. Write a Java program to find the subarray with the largest sum in a given circular array of integers.  

Example: Input : nums1 = { 2, 1, -5, 4, -3, 1, -3, 4, -1 } nums2 = { 1, -2, 3, 0, 7, 8, 1, 2, -3 } Output: The sum of subarray with the largest sum is 6 The sum of subarray with the largest sum is 21

68. Write a Java program to create all possible permutations of a given array of distinct integers.  

Example: Input : nums1 = {1, 2, 3, 4} nums2 = {1, 2, 3} Output: Possible permutations of the said array: [1, 2, 3, 4] [1, 2, 4, 3] .... [4, 1, 3, 2] [4, 1, 2, 3] Possible permutations of the said array: [1, 2, 3] [1, 3, 2] ... [3, 2, 1] [3, 1, 2]

69. Write a Java program to find the minimum subarray sum of specified size in a given array of integers.  

Example: Input : nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10} Output: Sub-array size: 4 Sub-array from 0 to 3 and sum is: 10

70. Write a Java program to find the smallest length of a contiguous subarray of which the sum is greater than or equal to a specified value. Return 0 instead.  

Example: Input : nums = {1, 2, 3, 4, 6} Output: Minimum length of a contiguous subarray of which the sum is 8, 2

71. Write a Java program to find the largest number from a given list of non-negative integers.  

Example: Input : nums = {1, 2, 3, 0, 4, 6} Output: Largest number using the said array numbers: 643210

72. Write a Java program to find and print one continuous subarray (from a given array of integers) that if you only sort the said subarray in ascending order then the entire array will be sorted in ascending order.  

Example: Input : nums1 = {1, 2, 3, 0, 4, 6} nums2 = { 1, 3, 2, 7, 5, 6, 4, 8} Output: Continuous subarray: 1 2 3 0 Continuous subarray: 3 2 7 5 6 4

73. Write a Java program to sort a given array of distinct integers where all its numbers are sorted except two numbers.  

Example: Input : nums1 = { 3, 5, 6, 9, 8, 7 } nums2 = { 5, 0, 1, 2, 3, 4, -2 } Output: After sorting new array becomes: [3, 5, 6, 7, 8, 9] After sorting new array becomes: [-2, 0, 1, 2, 3, 4, 5]

74. Write a Java program to find all triplets equal to a given sum in an unsorted array of integers.  

Example: Input : nums = { 1, 6, 3, 0, 8, 4, 1, 7 } Output: Triplets of sum 7 (0 1 6) (0 3 4)

75. Write a Java program to calculate the largest gap between sorted elements of an array of integers.  

Example: Original array: [23, -2, 45, 38, 12, 4, 6] Largest gap between sorted elements of the said array: 15

76. Write a Java program to determine whether numbers in an array can be rearranged so that each number appears exactly once in a consecutive list of numbers. Return true otherwise false.  

Example: Original array: [1, 2, 5, 0, 4, 3, 6] Check consecutive numbers in the said array!true

77. Write a Java program that checks whether an array of integers alternates between positive and negative values.  

Example: Original array: [1, -2, 5, -4, 3, -6] Check the said array of integers alternates between positive and negative values!true

78. Write a Java program that checks whether an array is negative dominant or not. If the array is negative dominant return true otherwise false.  

Example: Original array of numbers: [1, -2, -5, -4, 3, -6] Check Negative Dominance in the said array!true

79. Write a Java program that returns the missing letter from an array of increasing letters (upper or lower). Assume there will always be one omission from the array.  

Example: Original array of elements: [p, r, s, t] Missing letter in the said array: q

Java Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Follow us on Facebook and Twitter for latest update.

  • Weekly Trends and Language Statistics

Get the Reddit app

A subreddit for all questions related to programming in any language.

I give you the best 200+ assignments I have ever created (Java)

I'm a public school teacher who has taught the basics of programming to nearly 2,000 ordinary students over the past fifteen years.

I have seen a lot of coding tutorials online, but most of them go too fast ! Maybe some people can learn variables and loops and functions all in one day, but not my students.

So after some prompting from my wife, I've finally decided to post a link to the 200+ assignments I have used to teach Java to my own classes.

I almost never lecture.

Students learn programming by DOING it.

They work through the assignments at their own pace.

Each assignment is only SLIGHTLY harder than the previous one.

The concepts move at normal person speed.

Hopefully the programs are at least somewhat interesting.

Anyway, I'll be happy to help anyone get started. Installing the Java compiler (JDK) and getting your first program to compile is BY FAR the hardest part.

My assignments are at programmingbydoing.com .

Cheers, and thanks for reading this far.

-Graham "holyteach" Mitchell

tl;dr - If you've tried to teach yourself to code but quickly got lost and frustrated, then my assignments might be for you.

Edit : Wow! Thanks so much for all the support. I knew my assignments were great for my own students, but it is good to hear others enjoy them, too. Some FAQs:

I've created r/programmingbydoing . Feel free to post questions and help each other out there.

No, there are currently no solutions available. My current students use these assignments, too.

I'm sorry some of the assignments are a bit unclear. I do lecture sometimes, and I didn't write all of the assignments.

By continuing, you agree to our User Agreement and acknowledge that you understand the Privacy Policy .

Enter the 6-digit code from your authenticator app

You’ve set up two-factor authentication for this account.

Enter a 6-digit backup code

Create your username and password.

Reddit is anonymous, so your username is what you’ll go by here. Choose wisely—because once you get a name, you can’t change it.

Reset your password

Enter your email address or username and we’ll send you a link to reset your password

Check your inbox

An email with a link to reset your password was sent to the email address associated with your account

Choose a Reddit account to continue

IMAGES

  1. Core Java Assignments

    core java assignments for practice

  2. Day 1 Core Java Assignments

    core java assignments for practice

  3. Core Java Practice Tests

    core java assignments for practice

  4. GitHub

    core java assignments for practice

  5. Core Java Assignments: 2: Inheritance and Polymorphism

    core java assignments for practice

  6. Java

    core java assignments for practice

COMMENTS

  1. Java programming Exercises, Practice, Solution

    The best way we learn anything is by practice and exercise questions. Here you have the opportunity to practice the Java programming language concepts by solving the exercises starting from basic to more complex exercises. A sample solution is provided for each exercise. It is recommended to do these exercises by yourself first before checking ...

  2. Java Coding Practice

    Explore the Java coding exercises for practicing with commands below. First, read the conditions, scroll down to the Solution box, and type your solution. Then, click Verify (above the Conditions box) to check the correctness of your program. Exercise 1 Exercise 2 Exercise 3. Start task.

  3. Java Exercises

    That covers various Java Core Topics that can help users with Java Practice. So, with ado further take a look at our free Java Exercises to practice and develop your Java programming skills. Our Java programming exercises Practice Questions from all the major topics like loops, object-oriented programming, exception handling, and many more.

  4. 800+ Java Practice Challenges // Edabit

    How Edabit Works. This is an introduction to how challenges on Edabit work. In the Code tab above you'll see a starter function that looks like this: public static boolean returnTrue () { } All you have to do is type return true; between the curly braces { } and then click the Check button. If you did this correctly, the button will turn re ...

  5. Java Exercises

    Get certified by completing the JAVA course. Track your progress - it's free! Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.

  6. 50 Java Projects with Source Code for All Skill Levels

    Java, being one of the most popular programming languages globally, offers a vast array of opportunities for enthusiasts to practice and enhance their coding skills.Engaging in practical projects is one of the most effective ways to master Java programming. Here, we'll explore 50 Java projects with source code across different levels of complexity, suitable for beginners, intermediates, and ...

  7. Practice Java

    Complete your Java coding practice with our online Java practice course on CodeChef. Solve over 180 coding problems and challenges to get better at Java. ... But believe me, you can do it without any assistance! One thing to remember is to come prepared with a knowledge of core and advanced concepts. #CodeWell! (4.0) inaamulh66. Student.

  8. Solve Java

    Java Stdin and Stdout I. Easy Java (Basic) Max Score: 5 Success Rate: 96.83%. Solve Challenge. Java If-Else. Easy Java (Basic) Max Score: 10 Success Rate: 91.38%. Solve Challenge. Java Stdin and Stdout II. Easy Java (Basic) Max Score: 10 Success Rate: 92.79%. Solve Challenge. Java Output Formatting.

  9. Java exercises on Exercism

    Learn and practice Java by completing 147 exercises that explore different concepts and ideas. Join The Java Track Explore the Java exercises on Exercism. Unlock more exercises as you progress. They're great practice and fun to do! Code practice and mentorship for everyone.

  10. Java Coding Practice

    Description. Get starting with your java coding practice with these java exercises. There is a wide range of java problems to solve. Tricentis. Test: Scale, orchestrate, and accelerate test automation for any open source or proprietary tool.Trials and Demos >>. Ads via Carbon.

  11. Core Java Quiz

    Core Java Quiz | Java Online Test. There are a list of core java quizzes such as basics quiz, oops quiz, string handling quiz, array quiz, exception handling quiz, collection framework quiz etc. After clearing the exam, play our Belt Series Quiz and earn points. These points will be displayed on your profile page.

  12. Java Basic Programming Exercises

    Write a Java program to test if an array of integers contains an element 10 next to 10 or an element 20 next to 20, but not both. Click me to see the solution. 94. Write a Java program to rearrange all the elements of a given array of integers so that all the odd numbers come before all the even numbers. Click me to see the solution. 95.

  13. Fundamentals of Java Programming

    The Core Java module is a comprehensive training program that covers the fundamental concepts of the Java programming language. This module provides a deep understanding of Java programming and its key components. ... Practice Quiz • 30 minutes; Core Java ... To access graded assignments and to earn a Certificate, you will need to purchase ...

  14. Java Programming Exercises with Solutions

    Java Programming Exercises to Improve your Coding Skills with Solutions. All you need to excel on a Java interview ! Now with Java 8 Lamdbas and Streams exercises. ... The primary programming language is Java, as it is mature and easy to learn, but you can practice the same problems in any other language (Kotlin, Python, Javascript, etc ...

  15. Java Object Oriented Programming

    Object-oriented programming: Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or properties), and the code is in the form of procedures (often known as methods). A Java class file is a file (with the .class ...

  16. Java Collection Exercises: Boost Java Coding Skills

    Other Alternative Solutions. 3. Java Program to Compare Elements in a Collection. Input : List = [3, 5, 18, 4, 6] Output: Min value of our list : 3. Max value of our list : 18. Explanation: Comparison lead to result that the min of the list is 3 and max of list is 18. Similarly we can test for other Collections too.

  17. Java Programs

    Java, With the help of this course, students can now get a confidant to write a basic program to in-depth algorithms in C Programming or Java Programming to understand the basics one must visit the list 500 Java programs to get an idea. Users can now download the top 100 Basic Java programming examples in a pdf format to practice.

  18. Best Way To Start Learning Core Java

    Make yourself self-motivated to learn Java and build some awesome projects using Java. Do it regularly and also start learning one by one new concepts on Java. It will be very better to join some workshops or conferences on Java before you start your journey. 1) Data Types and Variables.

  19. Java Practice Programs

    Java is a popular programming language that is used to develop a wide variety of applications. One of the best ways to learn Java is to practice writing programs. Many resources are available online and in libraries to help you find Java practice programs. When practising Java programs, it is important to focus on understanding the concepts ...

  20. Practice

    Java. Platform to practice programming problems. Solve company interview questions and improve your coding intellect.

  21. Java Tutorial for Beginners: Learn Core Java Programming

    Java Tutorial Summary. This Java tutorial for beginners is taught in a practical GOAL-oriented way. It is recommended you practice the code assignments given after each core Java tutorial to learn Java from scratch. This Java programming for beginners course will help you learn basics of Java and advanced concepts.

  22. Java Array exercises: Array Exercises

    Java Array Exercises [79 exercises with solution] [ An editor is available at the bottom of the page to write and execute the scripts. Go to the editor] 1. Write a Java program to sort a numeric array and a string array. Click me to see the solution. 2. Write a Java program to sum values of an array. Click me to see the solution.

  23. I give you the best 200+ assignments I have ever created (Java)

    A subreddit for all questions related to programming in any language. I give you the best 200+ assignments I have ever created (Java) I'm a public school teacher who has taught the basics of programming to nearly 2,000 ordinary students over the past fifteen years. I have seen a lot of coding tutorials online, but most of them go too fast!