हिंदी

Explain the usage of IF Statement in Java.

Advertisements

प्रश्न

Explain the usage of IF Statement in Java.

स्पष्ट कीजिए
Advertisements

उत्तर

The if statement in Java is a decision-making or conditional statement used to execute a block of code only when a specified condition is true. It allows the program to make decisions and control the flow of execution based on a condition.

Working of the if Statement

  1. The if statement evaluates a condition that produces either true or false.
  2. If the condition is true, the statements inside the if block are executed.
  3. If the condition is false, the statements inside the if block are skipped.
  4. After executing or skipping the if block, program control moves to the next statement.

Syntax:

if (condition)
{ 
}

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 7: Statements and their Scope - EXERCISE [पृष्ठ १६३]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
अध्याय 7 Statements and their Scope
EXERCISE | Q 9. | पृष्ठ १६३
Advertisements
Share
Notifications



      Forgot password?
Use app×