
Mastering Java Loops and Methods

Quiz
•
Computers
•
University
•
Medium
Daniel Miller
Used 4+ times
FREE Resource
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following is the correct syntax for a for loop in Java that prints numbers from 1 to 5?
for (int i = 1; i <= 5; i++) { System.out.println(i); }
for (int i = 1; i < 5; i++) { System.out.println(i); }
for (int i = 0; i <= 5; i++) { System.out.println(i); }
for (int i = 1; i >= 5; i++) { System.out.println(i); }
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
What is the output of the following code? ```java int x = 10; if (x > 5) { System.out.println("A"); } else { System.out.println("B"); } ```
A
B
10
No output
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which keyword is used to indicate that a method does not return any value in Java?
void
return
static
public
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which logical operator in Java represents "AND"?
||
&&
!
&
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
What is the minimum number of times a do-while loop will execute its body?
0
1
2
It depends on the condition
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following is a correct method declaration for a public static method in Java that returns an int?
public static int myMethod() { }
static public void myMethod() { }
public int static myMethod() { }
int public static myMethod() { }
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following statements about while loops in Java is true?
The loop body may never execute if the condition is false initially.
The loop body always executes at least once.
The condition is checked after the loop body.
while loops cannot be nested.
Create a free account and access millions of resources
Similar Resources on Wayground
28 questions
Computer Programming 1 Practice Midterms

Quiz
•
University
25 questions
Java - SET -1

Quiz
•
University
30 questions
JAVA PROGRAMMING

Quiz
•
University
25 questions
Ардуино бойынша жалпы сұрақтар:

Quiz
•
University
30 questions
C-Programming

Quiz
•
University
25 questions
Aptitude Competition(FY)

Quiz
•
University
25 questions
JAVA BASICS

Quiz
•
University
25 questions
Java Methods Quiz

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University