Which of the following method calls illustrates the return value of a method as a parameter?
View Discussion Show Improve Article Save Article View Discussion Improve Article Save Article Function without return type stands for a void function. The void function may take multiple or zero parameters and returns nothing. Here, we are going to define a method which takes 2 parameters and doesn’t return anything. Syntax: public static void function(int a, int b)Example: public static void fun1(String 1, String 2){ // method execution code };Approach:
Code: Javaimport java.util.*; public class Main { public static void main(String args[]) { int a = 4; int b = 5; calc(a, b); } public static void calc(int x, int y) { int sum = x + y; System.out.print("Sum of two numbers is :" + sum); } } Output Sum of two numbers is :9Skip to main content This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. Func |