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

Java Loops Question Paper

The document contains a set of output-based questions related to Java loops, totaling 30 marks. It includes five questions that require predicting the output of given code snippets. Each question is designed to assess understanding of loop structures in Java.

Uploaded by

Tamilselvi
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 Loops Question Paper

The document contains a set of output-based questions related to Java loops, totaling 30 marks. It includes five questions that require predicting the output of given code snippets. Each question is designed to assess understanding of loop structures in Java.

Uploaded by

Tamilselvi
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 – Loops Based

Output Questions
Subject: Computer Science

Topic: Java Loops – Output Based Questions

Total Marks: 30

Time: 1 Hour

Instructions:

- Attempt all questions.

- Show the output only.

- Each question carries equal marks unless specified otherwise.

Section A: Output Based Questions [5 x 6 = 30 marks]


1. Q1. What will be the output of the following code?

for(int i = 1; i <= 5; i++) {


for(int j = 1; j <= i; j++) {
[Link]("*");
}
[Link]();
}
2. Q2. What will be the output of the following code?

for(int i = 5; i >= 1; i--) {


for(int j = 1; j <= i; j++) {
[Link](j);
}
[Link]();
}
3. Q3. Predict the output:

int i = 1;
while(i <= 5) {
[Link](i + " ");
i++;
}
4. Q4. What will be the output?

for(int i = 1; i <= 3; i++) {


for(int j = 1; j <= 3; j++) {
[Link](i * j + " ");
}
[Link]();
}
5. Q5. What will this code print?

for(int i = 0; i < 4; i++) {


for(int j = 0; j < 4; j++) {
if(i == j)
[Link]("#");
else
[Link]("*");
}
[Link]();
}
Answer Key
Q1. Output:
*
**
***
****
*****

Q2. Output:
12345
1234
123
12
1

Q3. Output:
12345

Q4. Output:
123
246
369

Q5. Output:
#***
*#**
**#*
***#

You might also like