0% found this document useful (0 votes)
78 views

Java Basic Programming

This document provides 150 Java programming exercises of varying levels of difficulty with solutions. It covers topics like printing output, performing basic math operations, taking user input, if/else conditional statements, loops, methods, arrays, and object-oriented programming concepts. Each exercise is accompanied by sample input/output and a button to view the solution code.

Uploaded by

Suat UĞURLU
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Java Basic Programming

This document provides 150 Java programming exercises of varying levels of difficulty with solutions. It covers topics like printing output, performing basic math operations, taking user input, if/else conditional statements, loops, methods, arrays, and object-oriented programming concepts. Each exercise is accompanied by sample input/output and a button to view the solution code.

Uploaded by

Suat UĞURLU
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Genel

Java Basic Programming : Exercises,


Practice, Solution
Last update on August 19 2022 21:50:34 (UTC/GMT +8 hours)

Java Basic Exercises [150 exercises with solution]


[An editor is available at the bottom of the page to write and execute the
scripts.]
1. Write a Java program to print 'Hello' on screen and then print your name on
a separate line. Go to the editor
Expected Output :
Hello
Alexandra Abramov

Click me to see the solution

2. Write a Java program to print the sum of two numbers. Go to the editor
Test Data:
74 + 36
Expected Output :
110

Click me to see the solution

3. Write a Java program to divide two numbers and print on the screen. Go to
the editor
Test Data :
50/3
Expected Output :
16

Click me to see the solution

4. Write a Java program to print the result of the following operations. Go to


the editor
Test Data:
a. -5 + 8 * 6

Genel
Genel

b. (55+9) % 9
c. 20 + -3*5 / 8
d. 5 + 15 / 3 * 2 - 8 % 3
Expected Output :
43
1
19
13

Click me to see the solution

5. Write a Java program that takes two numbers as input and display the
product of two numbers. Go to the editor
Test Data:
Input first number: 25
Input second number: 5
Expected Output :
25 x 5 = 125

Click me to see the solution

6. Write a Java program to print the sum (addition), multiply, subtract, divide
and remainder of two numbers. Go to the editor
Test Data:
Input first number: 125
Input second number: 24
Expected Output :
125 + 24 = 149
125 - 24 = 101
125 x 24 = 3000
125 / 24 = 5
125 mod 24 = 5

Click me to see the solution

7. Write a Java program that takes a number as input and prints its
multiplication table upto 10. Go to the editor
Test Data:
Input a number: 8
Expected Output :

Genel
Genel

8x1=8
8 x 2 = 16
8 x 3 = 24
...
8 x 10 = 80

Click me to see the solution

8. Write a Java program to display the following pattern. Go to the editor


Sample Pattern :
J a v v a
J a a v v a a
J J aaaaa V V aaaaa
JJ a a V a a

Click me to see the solution

9. Write a Java program to compute the specified expressions and print the
output. Go to the editor
Test Data:
((25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5))
Expected Output
2.138888888888889

Click me to see the solution

10. Write a Java program to compute a specified formula. Go to the editor


Specified Formula :
4.0 * (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11))
Expected Output
2.9760461760461765

Click me to see the solution

Genel

You might also like