
Java Programming Quiz
Authored by chrisbenedict sevilleno
Information Technology (IT)
11th Grade
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Sarah’s program takes two numbers and adds them only if both are positive. Which code snippet works?
if (num1 > 0 && num2 > 0) int sum = num1 + num2;
if (num1 > 0 || num2 > 0) int sum = num1 + num2;
if (num1 = num2) int sum = num1 + num2;
int sum = num1 + num2; if (sum > 0)
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
John’s calculator uses a Scanner named input to read two integers. Which line correctly declares and reads the first number?
int num1 = input.nextInt();
int num1 = Scanner.nextInt();
Scanner num1 = input.nextInt();
int num1 = input.nextLine();
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Maria checks if a number is between 10 and 20 (inclusive). Which condition should she use?
if (num >= 10 && num <= 20)
if (num >= 10 || num <= 10)
if (num >= 10 || num <= num2) int diff = num1 - num2;
if (num1 == num2) int diff = num1 - num2;
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Lisa’s program fails because she didn’t import Scanner and didn’t declare it properly. Which line fixes both?
import java.util.Scanner; Scanner scan = new Scanner(System.in);
Scanner scan = new Scanner(); import java.util.Scanner;
import Scanner; Scanner scan = System.in;
Scanner scan = new Scanner(System.in); import java;
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Anna’s program compares two numbers and prints “Equal” if they match. Which code is correct?
if (num1 == num2) System.out.println("Equal");
if (num1 = num2) System.out.println("Equal");
if (num1 != num2) System.out.println("Equal");
if (num1 > num2) System.out.println("Equal");
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Mike divides two numbers but only if the second isn’t zero. Which code prevents division by zero?
if (num2 != 0) int result = num1 / num2;
if (num2 == 0) int result = num1 / num2;
int result = num1 / num2; if (num2 != 0)
if (num1 != 0) int result = num1 / num2;
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Emily’s calculator lets the user choose between adding or multiplying. Which code structure works?
if (choice == 1) int result = num1 + num2; else if (choice == 2) int result = num1 * num2;
if (choice = 1) int result = num1 + num2; else int result = num1 * num2;
int result = num1 + num2; if (choice == 2) int result = num1 * num2;
if (choice > 0) int result = num1 + num2 * num2;
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
22 questions
Internet and App script
Quiz
•
5th Grade - University
20 questions
KELAS 7 BAB 6 ANALISIS DATA C. Pengolahan Data Dasar
Quiz
•
7th Grade - University
15 questions
LibreOffice Writer Styles Quiz
Quiz
•
10th Grade - University
20 questions
8NGS_P
Quiz
•
8th Grade - University
15 questions
JavaScript
Quiz
•
11th Grade
15 questions
Assessment on Imaging and Design for the Online Environment
Quiz
•
11th Grade
15 questions
PPMSG BIM2 PART 2
Quiz
•
9th - 12th Grade
24 questions
Mail Merge Quiz
Quiz
•
7th Grade - 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
Discover more resources for Information Technology (IT)
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
15 questions
Main Idea and Supporting Details.
Quiz
•
4th - 11th Grade
12 questions
Add and Subtract Polynomials
Quiz
•
9th - 12th Grade
13 questions
Model Exponential Growth and Decay Scenarios
Quiz
•
9th - 12th Grade
27 questions
7.2.3 Quadrilateral Properties
Quiz
•
9th - 12th Grade
7 questions
Amoeba Sisters Dihybrid Cross Punnett Square
Interactive video
•
9th - 12th Grade
10 questions
The Holocaust: Historical Overview
Interactive video
•
9th - 12th Grade
10 questions
Key Features of Quadratic Functions
Interactive video
•
8th - 12th Grade