Java Exercise For Beginners: How To Accept Input From The Keyboard?
Java Exercise For Beginners: How To Accept Input From The Keyboard?
2. Write a java program which displays the following multiple lines of text.
WELCOME
TO
JAVA
3. Write a Java program of two integers and then print the sum (addition), multiply, subtract,
divide and remainder of two numbers where the value of two numbers are x=10 and y=5
1|P ag e
5. Write a java program which print the area and circumference of a circle, given its radius. (Radius = 2)
Output
2|P ag e
Example 2: Check whether a number is even or odd
using ternary operator
import java.util.Scanner;
}
}
7. Write a java program that displays the largest integer numbers of three numbers
3|P ag e
8. Write a java program that displays the largest number of three integer numbers when those
numbers are given by a user or from a keyboard.
Output
4|P ag e
Exercise
Java program to calculate Maximum and Minimum of two numbers entered by user in console.
5|P ag e
Note:-
Java.util Package.
It contains the collections framework, legacy collection classes, event model, date and time
facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-
number generator, and a bit array).
6|P ag e
Method and Method overloading Exercise
Class MethodOverload includes two overloaded versions of method square— one that calculates the square
of an int (and returns an int) and one that calculates the square of a double (and returns a double). Although
these methods have the same name and similar parameter lists and bodies, think of them simply as different
methods. It may helptothinkofthemethodnamesas“squareofint”and“squareofdouble,”respectively.
7|P ag e
Exercise for Method overlaoding by creating a class for a method.
Output
8|P ag e