Search Header Logo

11AE-CSC60-SBQ-practice2

Authored by Computer Teacher

Other

11th Grade

Used 3+ times

11AE-CSC60-SBQ-practice2
AI

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

Which of the following statements is true about the if statement?

The if statement can have only one condition that evaluates to an integer value.

The if block is optional.

The else block is optional.

The if and else blocks should always be included within curly braces.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax for an if statement?

if (x < 10) { size = "Small"; } else (x < 20) { size = "Medium"; }

if (x < 10); { size = "Small"; } else (x < 20) { size = "Medium"; }

if (x < 10)

{ size = "Small";

}

else

{

size = "Medium";

}

if { size = "Small"; } else (x < 20) { size = "Medium"; }

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Assuming that the user provides 99 as input, what is the output of the following code snippet? int a; int b; a = 0; Scanner in = new Scanner(System.in); System.out.print("Please enter a number: "); b = in.nextInt(); if (b > 300) { a = b; } else { a = 0; } System.out.println("a: " + a);

a: 0
a: 99
a: 100
a: 300

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The following code snippet contains an error. What is the error? if (cost > 100); { cost = cost – 10; } System.out.println("Discount cost: " + cost);

Syntax error (won’t compile)
Logical error: use of an uninitialized variable
Logical error: if statement has do-nothing statement after if condition
Logical error: assignment statement does not show equality

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What kind of operator is the <= operator?

Ternary
Arithmetic
Inequality
Relational

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following operators is used as a relational operator?

=<
<=
=
!

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The operator !> stands for

not less than
not greater than.
not equal to.
this is not an operator in Java

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?