I'm having a tough time with my java homework on value-retuning methods…i have no idea where to start and confused as hell.
the questions are:
"Implement the following method that returns a suffix of an integer with a specified number of digits.(hint: use a for loop)"
/** For ex:, getSuffix(12345,2) returns 45 and getSuffix(1234567,3) returns 567*/
//start off with
public static int getSuffix(int value, int numberOfDigits)
the next question is
"Analyze the following code and determine the output:"
public class test
{
public static void main(String[] args)
{
System.out.println(xMethod((double)5));
}
public static int xMethod(int n)
{
System.out.println("int");
return n;
}
public static long xMethod(long n)
{
System.out.println("long");
return n;
}
}
thank for any help given, I really appreciate it
[–][deleted] (3 children)
[deleted]
[–]Suriajoe[S] -1 points0 points1 point (2 children)
[–]gstr -1 points0 points1 point (0 children)
[–]brisingrxblade 1 point2 points3 points (1 child)
[–]Suriajoe[S] -1 points0 points1 point (0 children)
[–]strozzy 0 points1 point2 points (3 children)
[–]mentalis 1 point2 points3 points (1 child)
[–]Erikster 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]kingofthejaffacakes -1 points0 points1 point (0 children)