Search Header Logo

Control Structures in Java

Authored by Adya Dalela

Computers

8th Grade

Used 87+ times

Control Structures in Java
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How many choices are possible when using a single if-else statement?

1

2

3

4

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How many "else" statements can you pair with a single "if" statement

1

<10

<20

As many as is needed.

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How many "else if" links can you have in an "if else if" ladder?

<10

<20

<30

As many as is needed to represent the situation

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Give the O/P.


int age= 5;

if (age > 6)

System.out.println("John is getting ice cream");

else

System.out.println("John is getting apple juice");

System.out.println("John is getting grapes);

John is getting ice cream

John is getting grapes

John is getting apple juice

John is getting grapes

John is getting apple juice

John is getting ice cream

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Suppose income is 4001, what is the output of the following code:
if (income > 3000) {
 System.out.println("Income is greater than 3000");
}
else if (income > 4000) {
 System.out.println("Income is greater than 4000");
}

no output
No output
Income is greater than 3000 
Income is greater than 3000 followed by Income is greater than 4000
Income is greater than 4000 followed by Income is greater than 3000

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Suppose you write the code to display "Cannot get a driver's license" if age is less than 16 and 
"Can get a driver's license" if age is greater than or equal to 16. 
Which of the following code is the best?

if (age < 16) 
 System.out.println("Cannot get a driver's license");
if (age >= 16) 
 System.out.println("Can get a driver's license");
if (age < 16) 
 System.out.println("Cannot get a driver's license");
else 
 System.out.println("Can get a driver's license");
if (age < 16) 
 System.out.println("Cannot get a driver's license");
else if (age >= 16) 
 System.out.println("Can get a driver's license");
if (age < 16) 
 System.out.println("Cannot get a driver's license");
else if (age > 16) 
 System.out.println("Can get a driver's license");
else if (age == 16) 
 System.out.println("Can get a driver's license");

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

The following code displays ___________.
double temperature = 50;
if (temperature >= 100)
 System.out.println("too hot");
else if (temperature <= 40)
 System.out.println("too cold");
else
 System.out.println("just right");

too hot
too cold
just right
too hot too cold just right

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?