Java Programming Quiz

Java Programming Quiz

11th Grade

20 Qs

quiz-placeholder

Similar activities

Grade 11 - IT - Quiz 1 - Mrs. Dina Mohamed

Grade 11 - IT - Quiz 1 - Mrs. Dina Mohamed

11th Grade

23 Qs

SAS Dasar Program Keahlian RPL Kelas X

SAS Dasar Program Keahlian RPL Kelas X

10th Grade - University

25 Qs

Unit 3: Basic Python & Console Interaction

Unit 3: Basic Python & Console Interaction

9th - 12th Grade

21 Qs

Экзамен C++ ОП

Экзамен C++ ОП

9th - 12th Grade

17 Qs

asessement formatif materi membuat algoritma penyelesaian

asessement formatif materi membuat algoritma penyelesaian

11th Grade

21 Qs

Python Programming Quiz

Python Programming Quiz

9th - 12th Grade

15 Qs

Kuis Pemrograman Python: Kalkulator Sederhana

Kuis Pemrograman Python: Kalkulator Sederhana

11th Grade

15 Qs

Grade 11(Quiz 1)

Grade 11(Quiz 1)

11th Grade

20 Qs

Java Programming Quiz

Java Programming Quiz

Assessment

Quiz

Information Technology (IT)

11th Grade

Hard

Created by

chrisbenedict sevilleno

Used 1+ times

FREE Resource

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;

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?