Class 8 ICSE - Java Coding Questions
Q1. Write a Java program to print the sum of two integers.
Input:
- Take two integers as input from the user.
Output:
- Print the sum of these integers.
Sample Input:
Enter the first number: 5
Enter the second number: 10
Sample Output:
The sum of 5 and 10 is 15.
Q2. Write a Java program to check if a number is even or odd.
Input:
- Take an integer input from the user.
Output:
- Print whether the number is even or odd.
Sample Input:
Enter a number: 7
Sample Output:
7 is an odd number.
Q3. Write a Java program to print the multiplication table of a number.
Input:
- Take an integer input from the user.
Output:
- Print the multiplication table of that number up to 10.
Sample Input:
Enter a number: 4
Sample Output:
4x1=4
4x2=8
...
4 x 10 = 40
Q4. Write a Java program to find the largest of three numbers.
Input:
- Take three integer inputs from the user.
Output:
- Print the largest number among the three.
Sample Input:
Enter first number: 3
Enter second number: 8
Enter third number: 5
Sample Output:
The largest number is 8.
Q5. Write a Java program to calculate the factorial of a number using a loop.
Input:
- Take an integer input from the user.
Output:
- Print the factorial of the number.
Sample Input:
Enter a number: 5
Sample Output:
The factorial of 5 is 120.