Computer Science, asked by nidachawdary, 2 months ago

Describe the conditional statement in java that does not accept the Boolean datatype value in the conditional statement.

Answers

Answered by Oreki
3

Switch is a conditional statement in Java that does not accept a boolean value in the conditional statement.

\textsf{\Large Switch}

   \textsf{Syntax}

       \texttt{switch ( control variable ) \{}

            \texttt{case 1 :}

                \texttt{// statements}

            \texttt{case 2 :}

                \texttt{// statements}

            \texttt{case 3 :}

                \texttt{// statements}

                 \texttt{.}

                 \texttt{.}

                 \texttt{.}

            \texttt{case n :}

                \texttt{// statements}

            \texttt{de\hspace{-.5em} fault :}

                \texttt{// Last block}

       \texttt{\}}

   \textsf{Explaination}

       A switch case statement is multiple branching statement where a

       particular statement is executed out of a number of options as per the

       user's choice.

       In this system, the control goes to a specific case and executes the

       statements for the given switch value.

       It also includes a 'default' case. The 'default' case is executed only when

       the switch value doesn't match any of the given cases.

   \textsf{Terms related to Switch Case statements}

       \textsf{Switch Block}

          A switch statement starts opening curly bracket '{' and ends with

          closing curly bracket '}' the cases which are enclosed within this

          which statement are known as the switch block.

       \textsf{Break statement}

          A break statement is used at the end of each case that is used as a

          case terminator.

          No statement is written after break in any specific case.

          This statement forces the control to exit from the switch block.

       \textsf{Fall through}

          If break statement is not used after case that control intersect the

          other case for execution this condition is known as fall through.

       \textsf{De\hspace{-.3em} fault case}

          This is a special case in switch case structure.

          It is executed when the value does not match with any of the case.

Similar questions