Answer:
public static int squared(int num){
return num*num;
}
Step-by-step explanation:
A complete java programming calling the method squared is given below:
import java.util.Scanner;
public class SquareExample {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the Number to Square");
int n = in.nextInt();
//Call the square method and pass the int number
int squareValue = squared(n);
//Print the the Square of the Number
System.out.println(squareValue);
}
public static int squared(int num){
return num*num;
}
}
In Java, a method is declared with its signature which is specified with an optional access modifier (in this case public), the return type (int in this case), the name of the method (squared) and the parameters in brackets.
Then we specify the methods behaviour by the codes within the braces following, in this case we simply find the square of n and return it.