Basic-Level Java Questions -Set2
----------------------------------
Q1. Sum of N Numbers
Question:
Write a Java program using a single class that:
Takes n integer inputs.
Calculates and prints the sum of all entered numbers.
Q2. Age Eligibility Checker
Question:
Write a Java program using a single class that:
Accepts the user’s name (String) and age (int).
Checks if the person is eligible to vote (age ≥ 18).
Displays an appropriate message based on the age.
Q3. Even Numbers in a Range
Question:
Write a Java program using a single class that:
Accepts two integers start and end from the user.
Prints all even numbers between start and end (inclusive).
Q4. Count Vowels in a String
Question:
Write a Java program using a single class that:
Accepts a string from the user.
Counts and displays the number of vowels in the string.
Q5. Find Maximum Element in an Array
Question:
Write a Java program using a single class that:
Accepts n integer values from the user and stores them in an array.
Finds and prints the largest number among them.
Medium-Level Java Questions
-----------------------------------
Q6. Student Grade Analyzer
Question:
Write a Java program using a single class that:
Accepts a student's name and marks in 5 subjects.
Calculates total and average marks.
Displays the student's name, total, average, and grade based on the average:
A: ≥ 90
B: 75–89
C: 60–74
D: 40–59
F: < 40
Q7. Palindrome Checker
Question:
Write a Java program using a single class that:
Accepts a word from the user.
Checks if the word is a palindrome (reads the same forward and backward).
Displays a suitable message.
Q8. Frequency of Characters in a String
Question:
Write a Java program using a single class that:
Accepts a sentence from the user.
Displays the frequency of each character (excluding spaces).
Difficult-Level Java Questions
-------------------------------------------
Q9. Remove Duplicate Elements from Array
Question:
Write a Java program using a single class that:
Accepts the size and elements of an integer array from the user.
Removes duplicate elements from the array.
Displays the updated array.
Q10. Find Longest Word in a Sentence
Question:
Write a Java program using a single class that:
Accepts a sentence from the user.
Identifies and prints the longest word in the sentence along with its length.