JAVA
Java Practical Questions
- Write a program to add two numbers entered by the user.
- Write a program to swap two numbers using a third variable.
- Write a program to swap two numbers without using a third variable.
- Write a program to find the remainder when a number is divided by another number.
- Write a program to check if a number is even or odd using the modulus operator.
- Write a program to calculate the area of a rectangle using multiplication.
- Write a program to calculate the square of a number using the `*` operator.
- Write a program to compute the cube of a number using the `*` operator.
- Write a program to calculate the average of three numbers.
- Write a program to check whether two numbers are equal or not.
If-Else
- Write a program to check whether a number is even or odd using if-else.
- Write a program to find the largest of two numbers using if-else.
- Write a program to find the largest of three numbers using nested if-else.
- Write a program to check whether a number is positive, negative, or zero.
- Write a program to check if a number is divisible by both 3 and 5.
- Write a program to find whether a character is a vowel or consonant.
- Write a program to check whether a number is prime or not.
- Write a program to check if a person is eligible to vote (18+ years).
- Write a program to determine whether a year is a leap year.
- Write a program to find the grade of a student based on marks.
Switch Case
- Write a program to display the name of the day based on a number (1-7).
- Write a program to display the name of a month based on a number (1-12).
- Write a program to check if a given character is a vowel or consonant using switch.
- Write a program to find whether a character is uppercase, lowercase, or a digit.
- Write a program to perform basic arithmetic operations (+, -, *, /) using switch.
- Write a program to find whether a number is even or odd using switch.
- Write a program to classify a triangle as equilateral, isosceles, or scalene using switch.
- Write a program to determine the type of a vehicle based on user input.
- Write a program to categorize a person’s BMI as underweight, normal, overweight, or obese.
- Write a program to determine traffic light actions based on color input.
Loops
- Write a program to print numbers from 1 to 100 using a for loop.
- Write a program to print even numbers between 1 to 50 using a while loop.
- Write a program to find the sum of the first 10 natural numbers.
- Write a program to calculate the factorial of a number using a loop.
- Write a program to reverse a given number using a loop.
- Write a program to display the Fibonacci series up to n terms.
- Write a program to print all prime numbers from 1 to 100.
- Write a program to find the greatest common divisor (GCD) of two numbers.
- Write a program to print a multiplication table for a given number.
- Write a program to count the number of digits in a number.
Loops with Conditionals
- Write a program to find the sum of even numbers from 1 to 100.
- Write a program to count the number of odd numbers between 1 and 100.
- Write a program to check if a number is a palindrome.
- Write a program to check if a number is an Armstrong number.
- Write a program to count the number of vowels in a given string.
- Write a program to check whether a number is prime or not.
- Write a program to find the sum of the digits of a given number.
- Write a program to calculate the sum of the first 50 prime numbers.
- Write a program to display all the factors of a given number.
- Write a program to find the largest digit in a given number.
Functions
- Write a function to find the sum of two numbers.
- Write a function to check if a number is prime.
- Write a function to swap two numbers.
- Write a function to calculate the factorial of a number.
- Write a function to reverse a given number.
- Write a function to find the maximum of two numbers.
- Write a function to find the minimum of two numbers.
- Write a function to compute the power of a number (x^y).
- Write a function to count the number of digits in a number.
- Write a function to find the sum of digits of a number.
Arrays
- Write a program to declare and initialize an array.
- Write a program to find the largest element in an array.
- Write a program to find the smallest element in an array.
- Write a program to calculate the sum of elements in an array.
- Write a program to reverse an array.
- Write a program to copy elements from one array to another.
- Write a program to search for an element in an array.
- Write a program to sort an array in ascending order.
- Write a program to sort an array in descending order.
- Write a program to merge two sorted arrays.
0 Comments