0% found this document useful (0 votes)
5 views2 pages

150 Proper Java Loop Questions

The document lists 150 important Java loop questions that are relevant for exams and interviews. It covers various types of loops, their syntax, and provides programming exercises related to loops, such as printing patterns, calculating sums, and checking number properties. Additionally, it addresses concepts like nested loops, infinite loops, and the use of break and continue statements.

Uploaded by

rohanlondhe7072
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

150 Proper Java Loop Questions

The document lists 150 important Java loop questions that are relevant for exams and interviews. It covers various types of loops, their syntax, and provides programming exercises related to loops, such as printing patterns, calculating sums, and checking number properties. Additionally, it addresses concepts like nested loops, infinite loops, and the use of break and continue statements.

Uploaded by

rohanlondhe7072
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

150 Important Java Loop Questions (For Exam & Interview)

1 What is a loop in Java?


2 Why are loops used in programming?
3 What are the types of loops in Java?
4 Explain the syntax of for loop.
5 Explain the syntax of while loop.
6 Explain the syntax of do-while loop.
7 Difference between while and do-while loop.
8 Difference between for and while loop.
9 What is an infinite loop? Give example.
10 How to stop an infinite loop in Java?
11 What is nested loop?
12 Write a program to print numbers from 1 to 10 using for loop.
13 Write a program to print numbers from 10 to 1 using while loop.
14 Write a program to print even numbers from 1 to 100.
15 Write a program to print odd numbers from 1 to 100.
16 Write a program to find sum of first N natural numbers.
17 Write a program to find factorial of a number.
18 Write a program to reverse a number.
19 Write a program to check palindrome number.
20 Write a program to count digits of a number.
21 Write a program to find sum of digits of a number.
22 Write a program to print multiplication table of a number.
23 Write a program to print tables from 1 to 10.
24 Write a program to find factors of a number.
25 Write a program to check prime number.
26 Write a program to print prime numbers between 1 and 100.
27 Write a program to check Armstrong number.
28 Write a program to print Fibonacci series.
29 Write a program to find largest digit in a number.
30 Write a program to find smallest digit in a number.
31 Write a program to count even and odd digits in a number.
32 Write a program to calculate power of a number using loop.
33 Write a program to print ASCII values using loop.
34 Write a program to print characters from A to Z.
35 Write a program to print characters from a to z.
36 Write a program to print numbers in triangle pattern.
37 Write a program to print star pattern (right triangle).
38 Write a program to print inverted star pattern.
39 Write a program to print pyramid pattern.
40 Write a program to print Floyd’s triangle.
41 Write a program to print number pattern.
42 Write a program to print diamond pattern.
43 Write a program to find sum of even numbers up to N.
44 Write a program to find sum of odd numbers up to N.
45 Write a program to check perfect number.
46 Write a program to print perfect numbers between 1 and 1000.
47 Write a program to check strong number.
48 Write a program to print strong numbers between 1 and 5000.
49 Write a program to check neon number.
50 Write a program to find LCM of two numbers using loop.
51 Write a program to find HCF of two numbers using loop.
52 Write a program to calculate factorial using while loop.
53 Write a program to calculate factorial using do-while loop.
54 Write a program to generate Fibonacci series using while loop.
55 Write a program to reverse a string using loop.
56 Write a program to check palindrome string using loop.
57 Write a program to count vowels and consonants using loop.
58 Write a program to remove spaces from string using loop.
59 Write a program to count words in a string using loop.
60 Write a program to find length of string without using length().
61 Write a program to copy one string into another using loop.
62 Write a program to find frequency of characters in string.
63 Write a program to print array elements using loop.
64 Write a program to find sum of array elements.
65 Write a program to find largest element in array.
66 Write a program to find smallest element in array.
67 Write a program to count even and odd numbers in array.
68 Write a program to reverse an array using loop.
69 Write a program to sort array using bubble sort.
70 Write a program to search element using linear search.
71 Write a program to print 2D array using nested loops.
72 Write a program to find sum of 2D array elements.
73 Write a program to print matrix in transpose form.
74 Write a program to add two matrices using loops.
75 Write a program to multiply two matrices using loops.
76 Write a program to print diagonal elements of matrix.
77 Write a program to check identity matrix.
78 Write a program to check sparse matrix.
79 Write a program to print multiplication table in matrix format.
80 Write a program to print Pascal triangle.
81 Write a program to generate prime numbers using nested loop.
82 Write a program to print number pattern using nested loop.
83 Write a program to print star pattern using nested loop.
84 Write a program to count prime numbers in an array.
85 Write a program to find factorial of each element in array.
86 Write a program to check each element of array is palindrome or not.
87 Write a program to print alternate elements of array.
88 Write a program to print elements at even index positions.
89 Write a program to print elements at odd index positions.
90 Write a program to find sum of diagonal elements of matrix.
91 Write a program to print boundary elements of matrix.
92 Write a program to count total numbers printed by nested loop.
93 Write a program to demonstrate break statement in loop.
94 Write a program to demonstrate continue statement in loop.
95 Write a program to demonstrate labeled break.
96 Write a program to demonstrate labeled continue.
97 What happens if loop condition is false initially?
98 Can for loop run without initialization? Explain.
99 Can while loop run without increment/decrement?
100Difference between break and continue.
101Explain scope of loop variables.
102What is enhanced for loop?
103Write a program using enhanced for loop.
104Difference between for loop and enhanced for loop.
105Can we use multiple variables in for loop? Explain.
106Write a program to print reverse triangle pattern.
107Write a program to print hollow rectangle pattern.
108Write a program to print hollow pyramid pattern.
109Write a program to print number diamond pattern.
110Write a program to print butterfly pattern.
111Write a program to print X pattern using stars.
112Write a program to print checkerboard pattern.
113Write a program to count total loops executed.
114Write a program to demonstrate nested while loop.
115Write a program to demonstrate nested do-while loop.
116Write a program to generate multiplication tables from 1 to N.
117Write a program to print numbers skipping multiples of 5.
118Write a program to stop loop when number becomes divisible by 7.
119Write a program to print prime factors of a number.
120Write a program to check automorphic number.
121Write a program to print automorphic numbers in a range.

You might also like