0% found this document useful (0 votes)
2 views3 pages

Java Questions 10th Standard

The document contains 30 practice questions aimed at 10th standard students focusing on Java programming concepts such as switch-case, if-else-if, loops, and debugging. Each section includes coding tasks, theoretical questions, and dry run exercises to enhance understanding of Java syntax and logic. The document serves as a comprehensive guide for students to practice and solidify their programming skills.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java Questions 10th Standard

The document contains 30 practice questions aimed at 10th standard students focusing on Java programming concepts such as switch-case, if-else-if, loops, and debugging. Each section includes coding tasks, theoretical questions, and dry run exercises to enhance understanding of Java syntax and logic. The document serves as a comprehensive guide for students to practice and solidify their programming skills.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Programming

30 Practice Questions for 10th Standard Students


Topics: Switch-Case | If-Else-If | Number Based | Looping | Statements | Dry Run | MCQs | Debugging | Rewrite

🔷 SECTION 1: Switch-Case
1. What will be the output of the following code?
int x = 2;
switch(x) {
case 1: [Link]("One"); break;
case 2: [Link]("Two"); break;
case 3: [Link]("Three"); break;
default: [Link]("Other"); }

2. Write a switch-case program to print the day name based on a number


(1=Monday, 2=Tuesday ... 7=Sunday).
(Write your answer below)

3. What happens if you remove all break statements from a switch-case? Explain
with an example.
(Write your answer below)

4. Write a switch-case program to print a grade based on marks: 90-100 → A, 70-89


→ B, 50-69 → C, Below 50 → Fail.
(Write your answer below)

🔷 SECTION 2: If-Else-If
5. Write a program using if-else-if to check whether a number is Positive, Negative,
or Zero.
(Write your answer below)

6. What will be the output of the following code?


int a = 15;
if(a > 20) { [Link]("Big"); }
else if(a > 10) { [Link]("Medium"); }
else { [Link]("Small"); }

7. Write a program to find the largest of three numbers using if-else-if.


(Write your answer below)

8. A student scores marks in 3 subjects. Write a program to print Pass only if all
three are >= 35, otherwise print Fail.
(Write your answer below)

🔷 SECTION 3: Number Based


9. Write a program to check whether a given number is Even or Odd.
(Write your answer below)

10. Write a program to check whether a number is Prime or Not.


(Write your answer below)
11. Write a program to find the Factorial of a number using a loop.
(Write your answer below)

12. Write a program to reverse a 3-digit number. (Example: 456 → 654)


(Write your answer below)

🔷 SECTION 4: Looping
13. What will be the output?
for(int i = 1; i <= 5; i++) {
[Link](i * 2 + " "); }

14. Write a program using a while loop to print the sum of digits of a number.
(Example: 123 → 6)
(Write your answer below)

15. Write a program using a do-while loop to print numbers from 10 to 1 in reverse.
(Write your answer below)

16. Write a program to print the following star pattern using loops:
*
* *
* * *
* * * *
* * * * *

🔷 SECTION 5: Java Statements Based


17. What is the difference between break and continue? Give one example of each.
(Write your answer below)

18. What will be the output?


for(int i = 1; i <= 10; i++) {
if(i == 5) continue;
if(i == 8) break;
[Link](i + " "); }

19. Explain the difference between while and do-while loop with an example where
the result is different.
(Write your answer below)

20. What is the purpose of the default statement in switch-case? Is it mandatory?


(Write your answer below)

🔷 SECTION 6: Dry Run / Output


21. Dry run and find the output:
int i = 0, sum = 0;
while(i < 5) { i++; sum = sum + i; }
[Link]("Sum = " + sum);
Answer: _______________

22. Find the output:


for(int i = 2; i <= 20; i = i + 3) { [Link](i + " "); }
Answer: _______________
23. Find the output:
int x = 5;
do { [Link](x); x = x - 2; } while(x > 0);
Answer: _______________

🔷 SECTION 7: Analytical MCQs


24. Which loop is guaranteed to execute at least once?
a) for loop b) while loop c) do-while loop d) None of the above
Answer: ______
25. What is the output of [Link](10 % 3); ?
a) 3 b) 1 c) 0 d) 10
Answer: ______
26. How many times will the following loop execute? for(int i = 10; i > 0; i = i - 3) { }
a) 3 b) 4 c) 10 d) Infinite
Answer: ______

🔷 SECTION 8: Debugging
27. Find and fix the error in this code:
int n = 5;
for(int i = 1, i <= n, i++) {
[Link](i); }
Error & Fix: _______________

28. Find the logical error in this code:


int n = 4;
if(n % 2 == 1) { [Link]("Even"); }
else { [Link]("Odd"); }
Error & Fix: _______________

🔷 SECTION 9: Rewrite in Different Format


29. Rewrite the following for loop using a while loop:
for(int i = 1; i <= 10; i++) {
[Link](i); }
(Rewrite using while loop below)

30. Rewrite the following if-else-if using a switch-case:


int day = 3;
if(day == 1) [Link]("Monday");
else if(day == 2) [Link]("Tuesday");
else if(day == 3) [Link]("Wednesday");
else [Link]("Invalid");
(Rewrite using switch-case below)

Total: 30 Questions | Good Luck! | Answer Key Available on Request

You might also like