Answer:
The output of the given code as follows:
Program:
public class Main //define class
{
public static void printSomething (int num, boolean val) //define method.
{
num--; //decrease value by 1.
System.out.print(val); //print value.
System.out.print(num); //print value.
}
public static void main(String[] args) //main method
{
printSomething(1, true); //calling function
printSomething(2, true); //calling function
}
}
Output:
true 0
true 1
Explanation:
In the question, it is given there is a method that is "printSomething" is defined. This method accepts two parameters that are num and val. where num is an integer variable and val is boolean variable that holds two values only that are true or false. inside the method, we decrease the value of the num variable by 1 and then we print the value of val and num variable. This function does not return any value because we use return type void.
The function is defined in the same class so, we call the function two times that can be described as:
- In first time calling we pass 1 and true value in function so it will "print true 0".
- In second time calling we pass 2 and true value in function so it will "print true 1".