w3resource

Java Programming Exercises, Practice, Solution

Java Exercises

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:

Note: If you are not habituated with Java programming you can learn from the following :

More to Come !

Popularity of Programming Language
Worldwide, Sept 2021 compared to a year ago:

`
Rank Change Language Share Trend
1 Python 29.48 % -2.4 %
2 Java 17.18 % +0.7 %
3 Javascript 9.14 % +0.8 %
4 C# 6.94 % +0.6%
5 PHP 6.49 % +0.4 %
6 C/C++ 6.49 % +0.9 %
7 R 3.59 % -0.5 %
8 up arrow TypeScript 2.18 % +0.3 %
9 Swift 2.1 % -0.4 %
10 down arrow Objective-C 2.06 % -0.6 %
11 up arrow Kotlin1.91% +0.3 %
12 down arrow Matlab 1.74 % -0.1 %
13   Go 1.52 % +0.1 %
14 VBA 1.22 % -0.0 %
15 up arrow Rust 1.14 % +0.1 %
16 down arrow Ruby 1.13 % -0.0 %
17   Scala 0.84 % +0.0 %
18 up arrow Ada 0.78 % +0.2 %
19 down arrow Visual Basic 0.75 % -0.0 %
20 up arrow Dart 0.57 % +0.0 %
21 up arrow Abap 0.53 % +0.1 %
22 up arrow Julia 0.52 % +0.1 %
23 down arrow Lua 0.52 % -0.0 %
24 up arrow Groovy 0.43 % +0.0 %
25 Cobol 0.35 % -0.1 %
26 down arrow Perl 0.26 % -0.2 %
27 up arrow Delphi/Pascal 0.17 % -0.1 %
28 down arrow Haskell 0.0 % -0.3 %

Source : https://pypl.github.io/PYPL.html

TIOBE Index for September 2021

Sept 2021 Sept 2020 Change Programming Language Ratings Change
1 1 C 11.83% -4.12%
2 3 up arrow Python 11.67% +1.20%
3 2 down arrow Java 11.12% -2.37%
4 4 C++ 7.13% +0.01%
5 5 C# 5.78% +1.20%
6 6 Visual Basic 4.62% +0.50%
7 7 JavaScript 2.55% +0.01%
8 14 up arrow Assembly language 2.42% +1.12%
9 8 down arrow PHP 1.85% -0.64%
10 10 SQL 1.80% +0.04%
11 22 up arrow Classic Visual Basic 1.52% +0.77%
12 17 up arrow Groovy 1.46% +0.48%
13 15 up arrow Ruby 1.27% +0.03%
14 11 down arrow Go 1.13% -0.33%
15 12 down arrow Swift 1.07% -0.31%
16 16 MATLAB 1.02% -0.07%
17 37 up arrow Fortan 1.01% +0.65%
18 9 down arrow R 0.98% -1.40%
19 13 down arrow Perl 0.78% -0.53%
20 29 up arrow Delphi/Object Pascal 0.77% +0.24%

Source : https://www.tiobe.com/tiobe-index/

List of Exercises with Solutions :

[ Want to contribute to Java exercises? Send your code (attached with a .zip file) to us at w3resource[at]yahoo[dot]com. Please avoid copyrighted materials.]

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



Java: Tips of the Day

Float vs double

Programmers often cannot select the precision they need for floating-point numbers. Float requires only 4 bytes, but it has only 7 significant digits, while Double is twice as accurate (15 digits), but twice as wasteful.

In fact, most processors are able to work with Float and Double equally effectively, so use the recommendation of Bjorn Stroustrup:

"Choosing the right accuracy in real-world problems requires a good understanding of the nature of machine computing. If you do not have it, either consult with someone, or study the problem yourself, or use double and hope for the best."

Ref: https://bit.ly/3y3CjL9