Decision Making in java switch case in Java
⚠ Report ✓ Question Verified Copy Link
The above program is an example of ..class Out { int a = 5; // Adding a variable to compare with x int cal() { int x = 10; if (x > a) { return --x; // Decrements x by 1 and returns 9 } else { return ++x; // Increments x by 1 and returns 11 } } public static void main(String[] args) { Out ob = new Out(); // Create an instance of the class int x = ob.cal(); // Call the method cal() and store the result in x System.out.println(x); // Print the value of x } }
Learn More MCQ Questions from Decision Making in java switch case in Java