Computer Applications
Given the method below, write a main() method that includes everything necessary to call given method.
int thrice (int x)
{
return x * 3 ;
}
User Defined Methods
16 Likes
Answer
public class Methodcall
{
int thrice (int x)
{
return x * 3 ;
}
public static void main(String args[])
{
Methodcall obj = new Methodcall();
int ans;
ans = obj.thrice(5);
}
}
Answered By
10 Likes
Related Questions
Identify the errors in the function skeletors given below :
float mult (int x, y) { }Identify the errors in the function skeletors given below :
float doer (int, float = 3.14) { }What is the principal reason for passing arguments by value ?
When an argument is passed by reference,
- a variable is created in the function to hold the argument's value.
- the function cannot access the argument's value.
- a temporary variable is created in the calling program to hold the argument's value.
- the function accesses the argument's original value in the calling program.