Java Programming Control Structures Quiz

SimplifiedLaplace avatar
SimplifiedLaplace
·
·
Download

Start Quiz

Study Flashcards

16 Questions

What are the three main control structures in any programming language?

Sequence, Selection, Iteration

Which control structure is used to choose between alternative courses of action?

Selection

What determines the order in which statements or instructions are carried out in a Java program?

Control Structures

Which keyword is used for the selection structure in Java?

if

What type of control structure is used for executing instructions repeatedly until a logical condition is satisfied?

Repetition/Iteration

In a Java program, which control structure is used when one group of statements is selected from several available groups?

if/else ladder(chain)

What happens if the expression in an if statement is false?

The statements following the if are not executed

Which operator is used to check if a value is greater than or equal to another value?

>=

In Java, what is the syntax for the if statement?

if (expression) { statement; }

What should be done after the if statement in Java to maintain proper code indentation?

3 space indentation

Which symbol is used in Java to check for equality between two values?

==

What does the following code do: if (balance > 0) { fee = 0; } ?

Sets fee to 0 if balance is positive

What does the following code do: if (hrsWked > 38) { System.out.print('Overtime hours: ' + (hrsWked - 38)); } ?

Prints 'Overtime hours' with the difference of hrsWked and 38

What does the following code do: if (length == width) { System.out.print('it is square'); } ?

Checks if length is equal to width

What does the following code do: if (totalPrice >= 100) { disc = totalPrice * 0.1; totalPrice = totalPrice - disc; } ?

Calculates total price after applying a discount of 10%

'Java Math Notation Description' mentions which operator for 'Greater than or equal to'?

Test your knowledge of Java programming control structures with this quiz. Topics include sequence, selection, and repetition/iteration control structures, as well as control statements like if, if/else, else/if, switch, for, while, and do/while.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser