Java Comprehensive Test
The test is of 100 marks and divided into three sections.
Section A: One-mark questions – 20 marks
Section B: Two-mark questions – 30 marks
Section C: Coding and Pseudocode – 50 marks
No theory or definition questions. All are logic-based or coding-based.
Section A – One Mark Questions (20 marks)
Answer all questions. Each carries 1 mark.
1. What is the output of: [Link](5 + 3 * 2);
2. Which loop executes at least once even if the condition is false?
3. Convert 1101 (binary) to decimal.
4. What is the remainder of 17 % 3?
5. Which Java keyword is used to exit from a loop?
6. Write the next value in the series: 2, 4, 8, 16, …
7. Convert decimal 25 to binary.
8. What will be the value of x after: int x = 5; x++; ?
9. Which loop is best when the number of iterations is known?
10. Convert hexadecimal A (10) to binary.
11. What is the output of: [Link](10/3);
12. Name the control structure used to check multiple conditions.
13. Convert octal 17 to decimal.
14. What is the initial value of an int array element by default in Java?
15. Write the output: [Link](2 == 2 && 3 > 5);
16. Convert decimal 100 to hexadecimal.
17. Write the output: [Link](7 >> 1);
18. Which loop is suitable for validating user input until correct?
19. What is the maximum value of a byte in Java?
20. Convert binary 1010 to hexadecimal.
Section B – Two Mark Questions (30 marks)
Answer all questions. Each carries 2 marks.
1. Write a Java for-loop to print all even numbers between 1 and 20.
2. Convert decimal 45 to binary and hexadecimal.
3. Write a do-while loop that asks the user for a number until they enter a negative number.
4. Using switch-case, write logic for days of the week (1=Monday … 7=Sunday).
5. Write a Java program snippet to calculate the factorial of 5 using a while loop.
6. Convert binary 111101 to decimal and octal.
7. Write pseudocode for finding the largest of three numbers.
8. Write a Java loop to print the first 10 terms of the Fibonacci sequence.
9. Convert hexadecimal 2F to decimal and binary.
10. Write pseudocode to check if a number is prime.
11. Write Java code using if-else-if to assign grades (>=90=A, >=75=B, >=50=C, else=Fail).
12. Convert octal 72 to decimal and binary.
13. Write a Java loop to calculate the sum of digits of a number 1234.
14. Write pseudocode for finding the minimum number in an array of size 10.
15. Convert binary 100110 to hexadecimal.
Section C – Coding and Pseudocode (50 marks)
This section has two parts.
Part I – Choice Questions (5 out of 7, 30 marks)
Answer any 5 questions. Each carries 6 marks.
1. Write a Java program to check if a given number is an Armstrong number.
2. Write pseudocode for a library management system that allows borrowing and returning of
books.
3. Write a Java program using switch-case to implement a basic calculator (+, -, *, /).
4. Write a Java program to print all prime numbers between 1 and 100.
5. Write pseudocode for an online food ordering system (menu display, order input, total
calculation).
6. Write a Java program to count vowels and consonants in a given string.
7. Write a Java program to generate and print the multiplication table of a number entered by the
user.
Part II – Case Studies (2 Questions, 20 marks)
Answer both questions. Each carries 10 marks.
1. Case Study: Hospital Queue System
Write pseudocode and then Java code for a hospital queue where Emergency patients are served
first, then VIP, then General. Implement using if-else-if.
2. Case Study: Student Result System
Write Java code to input marks of 5 subjects, calculate total, percentage, and grade assignment.
Extend logic to handle distinction if percentage >= 85.
Total: 100 marks