1.

Write a Method to calculate and return the sum of the square of the digits of a number'n' using recursive technique.The method declaration is as follows:int sumSq(int n)​

Answer»

Method to calculate and return the sum of the square of the digits of a number  'N' using recursive technique.

Explanation:

  • The method  is similar to a function in object-oriented programming to which parameters are passed and the operation is [performed and the result is RETURNED.
  • A class can have any number of METHODS.
  • The method can only the data known to its object.
  • In this method, the number is passed as in input through the VARIABLE n.
  • If the number is a single digit, it is squared and returned directly.
  • If the number has more than one digit, then modulo operation is performed to separate the digits and then it is squared.

public  static int int sumSq(int n)​

{

if (n < 10) return n^2;

return (((n % 10)^2) +sumSq(n/10));

}

Learn more about methods:

Write a java program to compute the amount that has to be paid to a person (employee) using the following rules for calculating tax.

brainly.in/question/15584326

What is the statement specifically called that involves a method in java​

brainly.in/question/13385154



Discussion

No Comment Found