- Java Programming Exercises, Practice, Solution
- Popularity of Programming Language Worldwide, July 2023 compared to a year ago:
- Java: Tips of the Day
- Java Exercises
- Exercises
- Count Your Score
- Start Java Exercises
- Kickstart your career
- COLOR PICKER
- Report Error
- Thank You For Helping Us!
- Saved searches
- Use saved searches to filter your results more quickly
- dostonhamrakulov/Programming-Exercises-and-implementation-in-Java
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
Java Programming Exercises, Practice, Solution
Java is the foundation for virtually every type of networked application and is the global standard for developing and delivering embedded and mobile applications, games, Web-based content, and enterprise software. With more than 9 million developers worldwide, Java enables you to efficiently develop, deploy and use exciting applications and services.
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 the solution.
Hope, these exercises help you to improve your Java programming coding skills. Currently, following sections are available, we are working hard to add more exercises . Happy Coding!
List of Java Exercises:
- Basic Exercises Part-I [ 150 Exercises with Solution ]
- Basic Exercises Part-II [ 99 Exercises with Solution ]
- Data Types Exercises [ 15 Exercises with Solution ]
- Conditional Statement Exercises [ 32 Exercises with Solution ]
- Java recursive method Exercises [ 15 Exercises with Solution ]
- Java Enum Types Exercises [ 5 Exercises with Solution ]
- Exercises on handling and managing exceptions in Java [ 7 Exercises with Solution ]
- Array [ 77 Exercises with Solution ]
- Java Inheritance Exercises [ 9 exercises with solution ]
- Java Abstract Classes Exercises [ 4 exercises with solution ]
- Java Thread Exercises [ 7 exercises with solution ]
- Java Miltithreading Exercises [ 10 exercises with solution ]
- Java Lambda expression Exercises [ 25 exercises with solution ]
- Java Generic Methods Exercises [ 7 exercises with solution ]
- Object-Oriented Programming [ 19 Exercises with Solution ]
- Java Interface Exercises [ 11 exercises with solution ]
- Java Encapsulation Exercises [ 7 exercises with solution ]
- Java Polymorphism Exercises [ 12 exercises with solution ]
- Stack [ 29 Exercises with Solution ]
- String [ 107 Exercises with Solution ]
- Streams [ 8 Exercises with Solution ]
- Date Time [ 44 Exercises with Solution ]
- Methods [ 23 Exercises with Solution ]
- Numbers [ 28 Exercises with Solution ]
- Input-Output-File-System [ 18 Exercises with Solution ]
- Collection [ 126 Exercises with Solution ]
- Math [ 27 Exercises with Solution ]
- Sorting [ 19 Exercises with Solution ]
- Search [ 7 Exercises with Solution ]
- Regular Expression [ 30 Exercises with Solution ]
- More..
Note: If you are not habituated with Java programming you can learn from the following :
More to Come !
Popularity of Programming Language Worldwide, July 2023 compared to a year ago:
Rank | Change | Language | Share | Trend |
---|---|---|---|---|
1 | Python | 27.43 % | -0.2 % | |
2 | Java | 16.19 % | -1.0% | |
3 | Javascript | 9.4 % | -0.1% | |
4 | C# | 6.77 % | -0.3% | |
5 | C/C++ | 6.44 % | +0.2 % | |
6 | PHP | 5.03 % | -0.4 % | |
7 | R | 4.45% | +0.1% | |
8 | TypeScript | 3.02 % | +0.3% | |
9 | Swift | 2.42 % | +0.4% | |
10 | Rust | 2.15% | +0.6% | |
11 | Objective-C | 2.13% | +0.0% | |
12 | Go | 2.01% | +0.0% | |
13 | Kotlin | 1.79 % | +0.0% | |
14 | Matlab | 1.59 % | +0.0% | |
15 | Ruby | 1.1% | -0.0% | |
16 | Ada | 1.06 % | +0.3 % | |
17 | Powershell | 1.06 % | +0.2 % | |
18 | VBA | 0.91 % | -0.1 % | |
19 | Dart | 0.86 % | -0.0 % | |
20 | Lua | 0.64 % | +0.0 % | |
21 | Visual Basic | 0.58 % | -0.0 % | |
22 | Abap | 0.57 % | +0.1 % | |
23 | Scala | 0.57 % | -0.2 % | |
24 | Julia | 0.42 % | -0.1 % | |
25 | Groovy | 0.42 % | -0.0 % | |
26 | Haskell | 0.3 % | +0.0 % | |
27 | Perl | 0.29 % | -0.0 % | |
28 | Cobol | 0.24 % | -0.0 % | |
29 | Delphi/Pascal | 0.16 % | +0.2 % |
TIOBE Index for July 2023
July 2023 | July 2022 | Change | Programming Language | Ratings | Change |
---|---|---|---|---|---|
1 | 1 | Python | 13.42% | -0.01% | |
2 | 2 | C | 11.56% | -1.57% | |
3 | 4 | C++ | 10.80% | +0.79% | |
4 | 3 | Java | 10.50% | -1.09% | |
5 | 5 | C# | 6.87% | +1.21% | |
6 | 7 | JavaScript | 3.11% | +1.34% | |
7 | 6 | Visual Basic | 2.90% | -2.07% | |
8 | 9 | SQL | 1.48% | -0.16% | |
9 | 11 | PHP | 1.41% | +0.21% | |
10 | 20 | MATLAB | 1.26% | +0.53% | |
11 | 18 | Fortran | 1.25% | +0.49% | |
12 | 21 | Scratch | 1.07% | +0.35% | |
13 | 12 | Go | 1.07% | -0.07% | |
14 | 8 | Assembly language | 1.01% | -0.64% | |
15 | 14 | Delphi/Object Pascal | 0.98% | -0.08% | |
16 | 15 | Ruby | 0.91% | -0.08% | |
17 | 29 | Rust | 0.89% | +0.47% | |
18 | 10 | Swift | 0.88% | -0.39% | |
19 | 19 | R | 0.87% | +0.11% | |
20 | 26 | COBOL | 0.86% | +0.33% |
List of Exercises with Solutions :
- HTML CSS Exercises, Practice, Solution
- JavaScript Exercises, Practice, Solution
- jQuery Exercises, Practice, Solution
- jQuery-UI Exercises, Practice, Solution
- CoffeeScript Exercises, Practice, Solution
- Twitter Bootstrap Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution
- C# Sharp Programming Exercises, Practice, Solution
- PHP Exercises, Practice, Solution
- Python Exercises, Practice, Solution
- R Programming Exercises, Practice, Solution
- Java Exercises, Practice, Solution
- SQL Exercises, Practice, Solution
- MySQL Exercises, Practice, Solution
- PostgreSQL Exercises, Practice, Solution
- SQLite Exercises, Practice, Solution
- MongoDB Exercises, Practice, Solution
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.
Java: Tips of the Day
Java Date vs Calendar
Date is a simpler class and is mainly there for backward compatibility reasons. If you need to set particular dates or do date arithmetic, use a Calendar. Calendars also handle localization. The previous date manipulation functions of Date have since been deprecated.
Both Date and Calendar are mutable, which tends to present issues when using either in an API.
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook
Java Exercises
You can test your Java skills with W3Schools’ Exercises.
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
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
COLOR PICKER
Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
Thank You For Helping Us!
Your message has been sent to W3Schools.
Top Tutorials
Top References
Top Examples
Get Certified
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Programming exercises in Java
dostonhamrakulov/Programming-Exercises-and-implementation-in-Java
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Exercises in Java programming language
Here, you can find a lot of programming exercise and implementations in Java.
Doston Hamrakulov
Description:
There are two integer variables(or whatever type) and you should swap them in manually without using any build in function and any other variable.
public class First_exercise < public static void main(String args[])< int number_1 = 8; int number_2 = 15; number_1 = number_1 + number_2; number_2 = number_1 - number_2; number_1 = number_1 - number_2; System.out.println("First: " + number_1); System.out.println("Second: " + number_2); > >
-[X] Exercise 2:
Description:
There is a String «Hello Doston Hamrakulov» and you need to reverse it. You have to show two ways of how to reverse the String by using build-in functions and doing manually.
public static void main(String args[])< String var = "Hello Doston"; System.out.println(var); System.out.println("\nUsing library:"); System.out.println(UsingLibrary(var)); System.out.println("\nDoing manually:"); System.out.println(Manually(var)); > public static String UsingLibrary(String name)< String newName = new StringBuilder(name).reverse().toString(); return newName; > public static String Manually(String name)< char dos[] = new char[name.length()]; for (int i = 1; i name.length(); i++)< if (i > name.length())< break; > else < dos[i-1] = name.charAt(name.length()-i); > > return new String(dos) + ""; >
Description:
Write a method in Java which takes String parameter and Character, then the method should remove the character from given String.
public static void main(String args[])< String str = "Doston HaBBBBBv"; System.out.println("Third exercise:\n\n" + str); System.out.println("Answer:\n\n" + MyMethod(str, 'B')); > private static String MyMethod(String str, char c)< if (str == null)< return null; > return str.replaceAll(Character.toString(c), ""); >
Description:
Write a Java program which takes input of Integer number and outputs the ODD or EVEN of the entered number.
public static void main(String args[])< int input; Scanner sc = new Scanner(System.in); System.out.println("Please, enter number"); input = sc.nextInt(); String num = "2019"; Integer a = Integer.valueOf(num); int d = a.intValue(); if ((input % 2) == 0)< System.out.println("\nNumber is EVEN"); > else < System.out.println("\nNumber is ODD"); > >
Description:
Write a Java program that reads an integer between 0 and 1000 and adds all the digits of that integer
public static void main(String args[])< System.out.println(getSUM(2222)); > static int getSUM(int num)< String a = String.valueOf(num); int sum = 0; for (int i = 0; i < a.length(); i++)< sum += Integer.parseInt(a.charAt(i) + ""); > return sum; >
Description:
Write java program which find the lowest common multiple of two Integer number.
public static void main (String args[])< System.out.println(MyMethod(8, 12)); > public static int MyMethod(int x, int y) < int a; a = (x > y) ? x : y; // a is greater number while(true) < if(a % x == 0 && a % y == 0) return a; ++a; > >
Description:
Write program that outputs 10 times without using any loop (‘for’, ‘while’, ‘do while’, ect.)
static int index = 0; static String temp = ""; public static void main(String[] args) < System.out.println(printMore("1_", 10)); > private static String printMore(String myStr, int i) < temp += myStr; index++; if (index < i)< printMore(myStr, i); > return temp; >
-[ ] Exercise 8: Write a Java method to count all vowels in a string.
Enjoy in open-source community 🙂