11AE-CSC60-SBQ-practice2

11AE-CSC60-SBQ-practice2

Assessment

Quiz

Other

11th Grade

Medium

Created by

Computer Teacher

Used 3+ times

FREE Resource

Student preview

quiz-placeholder

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

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?