
Mastering Java Loops and Methods
Quiz
ā¢
Computers
ā¢
University
ā¢
Practice Problem
ā¢
Medium
Daniel Miller
Used 5+ times
FREE Resource
Enhance your content in a minute
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.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
25 questions
Algorytmy i jezyki programowania
Quiz
ā¢
4th Grade - University
25 questions
GNIDOC ROUND 1
Quiz
ā¢
University
25 questions
Lenguajes programación
Quiz
ā¢
10th Grade - University
25 questions
UPRICCNASEP2
Quiz
ā¢
University
25 questions
AI Quiz
Quiz
ā¢
University
25 questions
Introduction to artificial intelligence and machine learning
Quiz
ā¢
University
25 questions
Intro PseInt
Quiz
ā¢
University
25 questions
Compro. Final 1/64 part1
Quiz
ā¢
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
ā¢
3rd Grade
20 questions
Equivalent Fractions
Quiz
ā¢
3rd Grade
25 questions
Multiplication Facts
Quiz
ā¢
5th Grade
22 questions
fractions
Quiz
ā¢
3rd Grade
20 questions
Main Idea and Details
Quiz
ā¢
5th Grade
20 questions
Context Clues
Quiz
ā¢
6th Grade
15 questions
Equivalent Fractions
Quiz
ā¢
4th Grade
20 questions
Figurative Language Review
Quiz
ā¢
6th Grade
