Decisions 14.0
Decision making is a common real-world problem that we experience in almost every aspect of our lives as humans. For example, when we wake up in the morning and try to decide whether to (or not) wear a particular clothing, to (or not) wear a particular shoe, to (or not) eat a particular meal, to (or not) go for a particular party, etc. All these exemplified scenarios constitute situations (in real-world domain) where we are challenged with making a decision in the form of either Yes or No response to the scenario/situation.

In Java programming, there exist primarily two (2) constructs or statements for formulating decision scenarios in programming. They are, namely:
  1. if {} statement:
    if (boolean condition == true) {
    	action
    }
    
    if (boolean condition == false) {
    	action
    }
    
    Pseudocode: Basic structure of an if {} statement
  2. switch {} statement:
    switch (variable) {
    	case (value-1): //variable == value-1
    		action
    	case (value-2): //variable == value-2
    		action
    	case (value-n): //variable == value-n
    		action
    }
    
    Pseudocode: Basic structure of an switch {} statement



4.1Operators in Java Programming
addition operation
Caption: Addition operation involving two (2) operands and one (1) operator
Basically, an operator is a predefined character that is used to denote a specific type of operation to be executed with respect to one or more operands. For example, taking into consideration the (adjacent) arithmetic operation, the addition + operator performs an operation involving two (2) operands (2, 3).

In this regard, most operators can either be categorized as one of the following:
  1. Unary Operator: Operates on only one (1) operand per evaluation.
  2. Binary Operator: Operates on only two (2) operands per evaluation.
  3. Ternary Operator: Operates on only three (3) operands per evaluation.

In Java, the following classes of operators do exist, viz:
  1. Arithmetic Operators
  2. Relational Operators
  3. Assignment Operators
  4. Logical Operators
  5. Bitwise Operators

Arithmetic Operators: The following arithmetic operators are existent in Java programming, namely:
  1. Addition Operator (+): This is a binary operator that computes the sum of two (2) corresponding operands.
  2. Subtraction Operator (-): This is a binary operator that computes the difference between two (2) corresponding operands.
  3. Multiplication Operator (*): This is a binary operator that computes the product of two (2) corresponding operands.
  4. Division Operator (/): This is a binary operator that uses a divisor (denominator) to divide a given dividend (numerator), and this operation yields a quotient (resultant).
  5. Modulus Operator (%): This is a binary operator that returns only the remainder with respect to the division of a dividend (numerator) by a divisor (denominator).
  6. Increment Operator (++): This is a unary operator that increments a sole (1) operand by a unit. It can be employed, with reference to the sole operand, either as a Prefix or as a Postfix. If the Increment Operator (++) is employed as a Prefix operator; then firstly, the operand is incremented and thereafter the incremented value is used for the corresponding computation. However, if the Increment Operator (++) is employed as a Postfix operator; then firstly, the operand is used for the corresponding computation and thereafter the operand is incremented.
  7. Decrement Operator (--): This is a unary operator that decrements a sole (1) operand by a unit. It can be employed, with reference to the sole operand, either as a Prefix or as a Postfix. If the Decrement Operator (--) is employed as a Prefix operator; then firstly, the operand is decremented and thereafter the decremented value is used for the corresponding computation. However, if the Decrement Operator (--) is employed as a Postfix operator; then firstly, the operand is used for the corresponding computation and thereafter the operand is decremented.
/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */
  
public class Decisions1 {
	
	public static void main(String[] args) {		
		int v1 = 10;
		int v2 = 15;
		
		/* Addition Operator */
		System.out.println(v1 + v2);
		System.out.println(-5 + v1 + v2 + 20);
		
		/* Subtraction Operator */
		System.out.println(v1 - v2);
		System.out.println(v2 - v1);

		/* Multiplication Operator */
		System.out.println(v1 * v2);
		System.out.println(2 * v1 * v2);

		/* Division Operator */
		System.out.println(v1 / v2);
		System.out.println(v2 / v1);

		/* Modulus Operator */
		System.out.println(v1 % v2);
		System.out.println(v2 % v1);

		/* Increment Operator */
		System.out.println(++v1 + ++v1); //Prefix Operator: 11 + 12 = 23 (current value of v1 is now 12)
		System.out.println(v2++ + v2++); //Postfix Operator: 15 + 16 = 31 (current value of v2 is now 17)

		/* NOTE: based on the aforementioned Increment operations.
		 * current value of v1 is now 12
		 * current value of v2 is now 17
		 */ 
		
		/* Decrement Operator */
		System.out.println(--v1 + --v1); //Prefix Operator: 11 + 10 = 21 (current value of v1 is now 10)
		System.out.println(v2-- + v2--); //Postfix Operator: 17 + 16 = 33 (current value of v2 is now 15)		
	}
	
} 
Code Snippet: Operations involving Arithmetic Operators in Java

Relational Operators: These are also known as Comparison Operators; and the following relational/comparison operators are existent in Java programming, namely:
  1. Equal-To Operator (==): This is a binary operator that returns true if both the left operand and the right operand possess the same value.
  2. Not-Equal-To Operator (!=): This is a binary operator that returns true either if the left operand does not possess the same value as the right operand or vice versa.
  3. Greater-Than Operator (>): This is a binary operator that returns true if the left operand possesses a value larger than the right operand.
  4. Lesser-Than Operator (<): This is a binary operator that returns true if the left operand possesses a value smaller than the right operand.
  5. Greater-Than or Equal-To Operator (>=): This is a binary operator that returns true if the left operand possesses a value that is larger than or of the same value as the right operand.
  6. Lesser-Than or Equal-To Operator (<=): This is a binary operator that returns true if the left operand possesses a value that is smaller than or of the same value as the right operand.
/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */
  
public class Decisions1 {
	
	public static void main(String[] args) {		
		int v1 = 10;
		int v2 = 15;
		
		/* Equal-To Operator */
		if (v1 == v2) {
			System.out.println(v1 + " is Equal-To " + v2);
		}
		
		/* Not-Equal-To Operator */
		if (v1 != v2) {
			System.out.println(v1 + " is Not-Equal-To " + v2);
		}
		
		/* Greater-Than Operator */
		if (v1 > v2) {
			System.out.println(v1 + " is Greater-Than " + v2);
		}
		
		/* Lesser-Than Operator */
		if (v1 < v2) {
			System.out.println(v1 + " is Lesser-Than " + v2);
		}
		
		/* Greater-Than or Equal-To Operator */
		if (v1 >= v2) {
			System.out.println(v1 + " is Greater-Than or Equal-To " + v2);
		}
		
		/* Lesser-Than or Equal-To Operator */
		if (v1 <= v2) {
			System.out.println(v1 + " is Lesser-Than or Equal-To " + v2);
		}
	}
	
} 
Code Snippet: Operations involving Relational/Comparison Operators in Java

Assignment Operators: The following assignment operators are existent in Java programming, namely:
  1. Basic Assignment Operator (=): A binary operator that assigns the data (or content) available on the right-hand-side onto the left-hand-side.
  2. Addition-Assignment Operator (+=): A binary operator that performs an addition of the left operand onto the right operand, and the resultant is assigned to the leftmost variable or operand.
  3. Subtraction-Assignment Operator (-=): A binary operator that performs a subtraction of the right operand from the left operand, and the resultant is assigned to the leftmost variable or operand.
  4. Multiplication-Assignment Operator (*=): A binary operator that performs a multiplication of the left operand and the right operand, and the resultant is assigned to the leftmost variable/operand.
  5. Division-Assignment Operator (/=): A binary operator that performs a division of the left operand by the right operand, and the resultant is assigned to the leftmost variable/operand.
  6. Modulus-Assignment Operator (%=): A binary operator that returns and assigns the remainder, from the division of the left operand by the right operand, to the leftmost variable or operand.
/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */
  
public class Decisions1 {
	
	public static void main(String[] args) {		
		int v1 = 10;
		int v2 = 15;
		
		/* Basic Assignment Operator */
		int v3;
		v3 = v1 + v2; //v3 = 10 + 15 = 25
		System.out.println("v3 = " + v3);
		
		/* Addition-Assignment Operator */
		int v4 = 0;
		v4 += (v1 + v2); //v4 = v4 + (v1 + v2) = 0 + (10 + 15) = 25
		System.out.println("v4 = " + v4);
		
		/* Subtraction-Assignment Operator */
		int v5 = 0;
		v5 -= v1; //v5 = v5 - v1 = 0 - 10 = -10
		System.out.println("v5 = " + v5);
		
		/* Multiplication-Assignment Operator */
		int v6 = 0;
		v6 *= (v1 * v2); //v6 = v6 * (v1 * v2) = 0 * (10 * 15) = 0
		System.out.println("v6 = " + v6);
		
		/* Division-Assignment Operator */
		int v7 = 20;
		v7 /= v1; //v7 = v7 / v1 = 20 / 10 = 2
		System.out.println("v7 = " + v7);
		
		/* Modulus-Assignment Operator */
		double v8 = 20.5;
		v8 %= v1; //v8 = v8 % v1 = 20.5 / 10 = 0.5
		System.out.println("v8 = " + v8);
	}
	
} 
Code Snippet: Operations involving Assignment Operators in Java

Logical Operators: The following logical operators are existent in Java programming, namely:
  1. Logical-AND Operator (&&): A binary operator that is used to compare two (2) expressions; and it returns true if both expressions are true.
  2. Logical-OR Operator (||): A binary operator that is used to compare two (2) expressions; and it returns true if at least one (1) of the expressions is true.
  3. Logical-NOT Operator (!): A unary operator that is used to evaluate a single (1) expression or operand; and it tests if an expression evaluates to a false value or it negates the initial truth value of an operand.
/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */
  
public class Decisions1 {
	
	public static void main(String[] args) {		
		int v1 = 10;
		int v2 = 15;
		
		/* Logical-AND Operator */
		if ((v1 > 10) && (v2 > 0)) { //if (false && true) { }
			System.out.println("Both expressions are true");
		}
		
		/* Logical-OR Operator */
		if ((v1 > 10) || (v2 > 0)) { //if (false || true) { }
			System.out.println("At least one of the expressions is true");
		}
		
		/* Logical-NOT Operator */
		if (!(v1 > 10)) { //if ((v1 > 10) == false) { }
			System.out.println("This expression is false");
		}
		if (v1 > 10) { //if ((v1 > 10) == true) { }
			System.out.println("This expression is true");
		}
	}
	
} 
Code Snippet: Operations involving Logical Operators in Java

Bitwise Operators: Just as the name implies; firstly, these operators convert its operands to binary values, and thereafter, these binary values are evaluated bit-by-bit. Thus, the following bitwise operators exsit in Java programming, namely:
  1. Bitwise-AND Operator (&): A binary operator that is used to compare bit-by-bit the binary representations of two (2) operands; and it returns 1 (or true) if both bits being compared are equals 1 (or true).
  2. Bitwise-OR Operator (|): A binary operator that is used to compare bit-by-bit the binary representations of two (2) operands; and it returns 1 (or true) if at least one (1) of the bits being compared is equal 1 (or true).
  3. Bitwise-Exclusive-OR Operator (^): A binary operator that compares bit-by-bit the binary representations of two (2) operands; and it returns 1 (or true) if and only if one (1) of the bits being compared is equal 1 (or true).
  4. Bitwise-NOT Operator (~): A unary operator that is used to evaluate the binary representation of a single (1) operand; and it negates all the bits present in the binary representation of the operand.
/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */
  
public class Decisions1 {
	
	public static void main(String[] args) {		
		int v1 = 10; //8-bits Binary Representation = 00001010
		int v2 = 15; //8-bits Binary Representation = 00001111
		
		/* Bitwise-AND Operator */
		System.out.println(v1 & v2); //(00001010 & 00001111 == 00001010) == 10 (Decimal or Base-10)
		
		/* Bitwise-OR Operator */
		System.out.println(v1 | v2); //(00001010 | 00001111 == 00001111) == 15 (Decimal or Base-10)
		
		/* Bitwise-Exclusive-OR Operator */
		System.out.println(v1 ^ v2); //(00001010 ^ 00001111 == 00000101) == 5 (Decimal or Base-10)
		
		/* Bitwise-NOT Operator */
		System.out.println(~v1); //(~00001010 == 11110101) == -11 (Decimal on signed 2's complement)		
		System.out.println(~v1); //(~00001010 == 11110101) == 245 (Decimal or Base-10)
	}
	
} 
Code Snippet: Operations involving Bitwise Operators in Java



4.2Variants of the if {} Statement
  1. if {} statement:
    if (boolean condition == true) {
    	action
    }
    
    if (boolean condition == false) {
    	action
    }
    
    Pseudocode: if {} statements

  2. if-else {} statement:
    if (boolean condition == true) {
    	action
    }
    else { //(boolean condition == false)
    	action
    }
    
    Pseudocode: if-else {} statement

  3. if-else-if {} statement:
    if (boolean condition-1 == true) {
    	action
    }
    else if (boolean condition-2 == true) {
    	action
    }
    else { //(boolean condition-1 == false) and (boolean condition-2 == false)
    	action
    }
    
    Pseudocode: if-else-if {} statement

  4. Nested if {} / if-else {} / if-else-if {} statements:
    if (boolean parent-condition == true) {
    	if (boolean child-condition-1 == true) {
    		action
    	}
    	else if (boolean child-condition-2 == true) {
    		action
    	}
    	else { //(boolean child-condition-1 == false) and (boolean child-condition-2 == false)
    		action
    	}
    }
    else { //(boolean parent-condition == false)
    	action
    }
    
    Pseudocode: Nested if {} / if-else {} / if-else-if {} statements

  5. Ternary (or Conditional) Operator: This operator can simply be considered as a "compression" of the if-else {} statement.
    
    (boolean condition)  ?  action (condition == true)  :  action (condition == false)
    
    
    Pseudocode: Ternary (or Conditional) operator


Exercise 1: Consider a scenario where two (2) consecutive numbers are requested from a user. Thus, we have been tasked with the responsibility of designing and developing a Java program that processes these inputs from the user and compares them. Thus, the program should be capable of stating which of the numbers is greater, lesser, or if both numbers are equal.

In this regard, below is an algorithm (pseudocode) for designing and developing our Java program.
Declare/Instantiate an instance-variable of the "Scanner" class.

Declare and initialize two (2) variables of "double" (data) type: d1 and d2.

Prompt the user for two (2) consecutive inputs, and store them into d1 and d2, respectively.

if (d1 > d2) {
	PRINT: d1 is greater than d2
}
else if (d1 < d2) {
	PRINT: d1 is lesser than d2
}
else {
	PRINT: d1 is equal to d2
}
Pseudocode: Exercise 1

/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */

import java.util.Scanner; 
  
public class Decisions1 {
	
	public static void main(String[] args) {
		/* Create an instance-variable of the "Scanner" class.
		Scanner usrInput = new Scanner(System.in);
		
		//Declaration of variables
		double d1, d2;
		
		//Prompt user for inputs
		System.out.print("Please enter two (2) numbers separated by a space character: ");
		d1 = usrInput.nextDouble();
		d2 = usrInput.nextDouble();
		
		//Comparison logic using an "if-else-if {}" statement
		if (d1 > d2) {
			System.out.println(d1 + " is greater than " + d2);
		}
		else if (d1 < d2) {
			System.out.println(d1 + " is lesser than " + d2);
		}
		else {
			System.out.println(d1 + " is equal to " + d2);
		}
		
		//Flushes and closes the "Scanner" buffer so as to prevent resource leakage/wastage.
        usrInput.close();
	}
	
} 
Code Snippet: Solution 1 with reference to Exercise 1

/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */

import java.util.Scanner; 
  
public class Decisions1 {
	
	public static void main(String[] args) {
		/* Create an instance-variable of the "Scanner" class.
		Scanner usrInput = new Scanner(System.in);
		
		//Declaration of variables
		double d1, d2;
		
		//Prompt user for inputs
		System.out.print("Please enter two (2) numbers separated by a space character: ");
		d1 = usrInput.nextDouble();
		d2 = usrInput.nextDouble();
		
		//Comparison logic using "if {}" statements
		if (d1 > d2) {
			System.out.println(d1 + " is greater than " + d2);
		}
		if (d1 < d2) {
			System.out.println(d1 + " is lesser than " + d2);
		}
		if (d1 == d2) {
			System.out.println(d1 + " is equal to " + d2);
		}
		
		//Flushes and closes the "Scanner" buffer so as to prevent resource leakage/wastage.
        usrInput.close();
	}
	
} 
Code Snippet: Solution 2 with reference to Exercise 1

/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */

import java.util.Scanner; 
  
public class Decisions1 {
	
	public static void main(String[] args) {
		/* Create an instance-variable of the "Scanner" class.
		Scanner usrInput = new Scanner(System.in);
		
		//Declaration of variables
		double d1, d2;
		
		//Prompt user for inputs
		System.out.print("Please enter two (2) numbers separated by a space character: ");
		d1 = usrInput.nextDouble();
		d2 = usrInput.nextDouble();
		
		//Comparison logic using an "if-else {}" statement and a "Ternary" operator
		if (d1 == d2) {
			System.out.println(d1 + " is equal to " + d2);
		}
		else {
			System.out.println((d1 > d2) ? (d1 + " is greater than " + d2) : (d1 + " is lesser than " + d2));
		}
		
		//Flushes and closes the "Scanner" buffer so as to prevent resource leakage/wastage.
        usrInput.close();
	}
	
} 
Code Snippet: Solution 3 with reference to Exercise 1

Exercise 2: Now, consider solution 2 with reference to Exercise 1 above. If a semicolon (;), which is used to end any line of code statement in Java, is appended after the condition segment of an if {} statement; then this abruptly truncates the entire logic of the if {} statement. Hence, the code statement(s) within the curly parantheses, {...}, of the if {} statement get executed irrespective of the condition segment.
/**
 * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
 * @course ProgrammingLessons (proglessons).
 * @title Decisions 1.
 * @author Dr. Bonaventure Chidube Molokwu.
 */

import java.util.Scanner; 
  
public class Decisions1 {
	
	public static void main(String[] args) {
		/* Create an instance-variable of the "Scanner" class.
		Scanner usrInput = new Scanner(System.in);
		
		//Declaration of variables
		double d1, d2;
		
		//Prompt user for inputs
		System.out.print("Please enter two (2) numbers separated by a space character: ");
		d1 = usrInput.nextDouble(); //INPUT: 3
		d2 = usrInput.nextDouble(); //INPUT: 5
		
		//Comparison logic using "if {}" statements
		if (d1 > d2); //<-- Semicolon here truncates the "if {}" statement
		{
			System.out.println(d1 + " is greater than " + d2); //PRINT: 3 is greater than 5
		}
		if (d1 < d2); //<-- Semicolon here truncates the "if {}" statement
		{
			System.out.println(d1 + " is lesser than " + d2); //PRINT: 3 is lesser than 5
		}
		if (d1 == d2); //<-- Semicolon here truncates the "if {}" statement 
		{
			System.out.println(d1 + " is equal to " + d2); //PRINT: 3 is equal to 5
		}
		
		//Flushes and closes the "Scanner" buffer so as to prevent resource leakage/wastage.
        usrInput.close();
	}
	
} 
Code Snippet: Abruptly truncating the condition segment of an if {} statement with semicolon (;)



4.3Practice Exercise
  1. Which of the following statements is/are TRUE with respect to an if {} statement?
    • It must possess an if {} block
    • It must possess an else {} block
    • It must not possess an if {} block
    • It must not possess an else {} block
    • All of the above

  2. Consider the code snippet below, if the code compiles then what is the expected output; otherwise, state the expected error.
    /**
     * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
     * @course ProgrammingLessons (proglessons).
     * @title Decisions 1.
     * @author Dr. Bonaventure Chidube Molokwu.
     */
    
    int v1=1, v2=2;
    
    System.out.println(++v1 * ++v1 + v2++);
    

  3. Consider the code snippet below, if the code compiles then what is the expected output; otherwise, state the expected error.
    /**
     * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
     * @course ProgrammingLessons (proglessons).
     * @title Decisions 1.
     * @author Dr. Bonaventure Chidube Molokwu.
     */
    
    int v1=1, v2=2;
    
    System.out.println(v2++ + ++v2 + ++v1 * 2);
    

  4. What is the expected output with reference to the code snippet below?
    /**
     * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
     * @course ProgrammingLessons (proglessons).
     * @title Decisions 1.
     * @author Dr. Bonaventure Chidube Molokwu.
     */
      
    public class Decisions1 {
    	
    	public static void main(String[] args) {
    		float rentCost = 1000F;
    		
    		if (rentCost < 1000f); {
    			System.out.println("Rent is quite affordable with regard to the global inflation rates.");
    		}		
    		if (rentCost > 1500f) {
    			System.out.println("Rent is relatively expensive with regard to the global inflation rates.");
    		}
    		else {
    			System.out.println("My rent for a studio apartment is: " + rentCost);
    		}
    	}
    	
    } 
    

  5. What is the expected output with reference to the code snippet below?
    /**
     * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
     * @course ProgrammingLessons (proglessons).
     * @title Decisions 1.
     * @author Dr. Bonaventure Chidube Molokwu.
     */
      
    public class Decisions1 {
    	
    	public static void main(String[] args) {
    		float rentCost = 1000F;
    		
    		if (rentCost < 1000f); {
    			System.out.println("Rent is quite affordable with regard to the global inflation rates.");
    		}		
    		if (rentCost > 1500f); {
    			System.out.println("Rent is relatively expensive with regard to the global inflation rates.");
    		}
    		if ((rentCost >= 1000f) && (rentCost <= 1500f)); {
    			System.out.println("My rent for a studio apartment is: " + rentCost);
    		}
    	}
    	
    } 
    

  6. Which of the following if {...} statements, with regard to the code snippet below, will resolve to or return TRUE?
    /**
     * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
     * @course ProgrammingLessons (proglessons).
     * @title Decisions 1.
     * @author Dr. Bonaventure Chidube Molokwu.
     */
    
    int caseStatus = 1;
    boolean flagVal = true;
    
    • if (caseStatus) {...}
    • if (flagVal == "true") {...}
    • if (flagVal) {...}
    • if (caseStatus == true) {...}
    • None of the above

  7. Consider the code snippet below, if the code compiles then what is the expected output; otherwise, state the expected error.
    /**
     * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
     * @course ProgrammingLessons (proglessons).
     * @title Decisions 1.
     * @author Dr. Bonaventure Chidube Molokwu.
     */
    
    int i1 = 100;
    int v1;
    
    if (i1 = 100) {
    	v1 = i1 * 3;
    }
    

  8. Which of the following is a valid operator in Java?
    • !<
    • !>
    • !!
    • %
    • All of the above

  9. Consider the code snippet below, if the code compiles then what is the expected output; otherwise, state the expected error.
    /**
     * @copyright © www.proglessons.com 2024. ALL RIGHTS RESERVED.
     * @course ProgrammingLessons (proglessons).
     * @title Decisions 1.
     * @author Dr. Bonaventure Chidube Molokwu.
     */
    
    int i1=99, v1=2;
    
    if (100 % v1) {
    	v1 = i1++;
    	System.out.println("The processed output value is: " + v1);
    }	
    

Sponsored Ads