What will be printed as a result of the following code execution?

public class Test {
    public static void main(String[] args) {
        int i = 1;
    static void add(int i) {
        i += 2;
The value of the i variable increases by 1 each time it is transferred to the corresponding method.
A variable with the same name is used inside the add() method, but any actions performed under it do not modify the initial variable.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes