Archive d’étiquettes pour : Call

In JavaScript, the onclick event of the button is used to associate any JavaScript function with it. Whenever the user presses the button, the attached function will be triggered. JavaScript provides built-in features such as addevent listener et onclick events to execute multiple functions with a single click. This event supports all the famous web browsers. In this article, you will learn how to call multiple JavaScript functions with an onclick event.

How to Call Multiple JavaScript Functions With an onclick Event?

The onclick event executes multiple methods in sequential order with a single click and supports multiple browsers. The onclick event makes the script clear and understandable by separating the functions with a semicolon for the users. The following example refers to the practical implementation of the onclick event.


An example is provided of calling multiple functions by using the onclick event in JavaScript. For this purpose, the code is written as below:


<h2>An example of using multiple methods by onclick event </h2>
// An example of using multiple methods by onclick event
function method1() {
document.write («First Method is called»);
document.write («Welcome to JavaScript World»);
function method2() {
document.write («Second Method is called»);
document.write (» Welcome to Linuxhint»);
<p>Press magic button to call the multiple functions</p>
<input type=«button» onclick = «method1(); method2()» value = «Press the Magic Button» >

The description of the code is as follows:

    • Two functions named method1() et method2() are defined that are to be called after the onclick event.
    • After that, a button is created using the <form> tag.
    • On the onclick event of the button, the methods method1() et method2() will be triggered.


A button named “Press the Magic Button” is utilized to execute the multiple methods by its onclick event. After pressing the button, method1 et method2 are called to display the information present in it.

After pressing the button, two methods are called and display messages “Welcome to JavaScript World” et “Welcome to Linuxhint”.


In JavaScript, an onclick event is employed to call multiple functions with a single click. These functions are placed in the onclick event of the button type. This post demonstrates the usage of the onclick event to call multiple functions in JavaScript. For a better understanding, we have demonstrated an example that shows how multiple functions are called with a single click.

Source link

In Java, there are two types of function parameters: The Coetáneo parameter and the Formal parameter. Coetáneo parameters are passed during the function call in another function, whereas formal parameters are the parameters added at the function definition.

In functions, there are two ways to pass an argument or parameters: Call by value and Call by reference. The purpose of this article is to focus on how to call by reference in Java.

How to Call by Reference in Java?

When a function or a method is called in Java, call by reference is the term that refers to a parameter. This method’s core feature is that we use it to refer to the address of a variable. As a result, any change in the variable’s address will be reflected whenever the function that uses it is called or invoked.

Let’s try some examples with the help of the specified method.

Example 1

In this example, first, we will create a method named “add()” by passing two integer type parameters, “x” et “y”. This method will output the sum of the given numbers. Also, the parameters of this method are called the formal parameters:

static int add(int x,int y)
   return x+y;

In the main() method, we call the add() method by passing the parameters that refer to the address of the formal parameters. Here, “a” et “b” are the reference parameters for variables “x” et “y”:

public static void main(String[] args) {
    int a=15;
       int b=83;
    System.out.println(«The sum of numbers a and b: « + add(a,b));


The given output indicates that the added parameters are successfully accessed and utilized:

Example 2

In this example, we have two methods: “ref()” et “main()”. The ref() method will add the value of the specified parameters and then multiply it by “3”:

In the main() method, the third line calls the ref() method by passing arguments “a” et “b” that refers to the address of the formal parameters “x” et “y”:

public static void main(String[] args) {
         int a=15;
         int b=83;



We compiled all the instructions related to calling by reference in Java.


In Java, you can call the method by passing an argument as a reference in contemporáneo parameters. Invoking a method by using call by reference means the argument refers to the variable’s address. Whenever a function is called, the added changes will also reflect the variable. In this article, we have discussed the method for calling by reference in Java.

Source link