Menu
Question Index
...

What will be the output of the following program?

public class Array {
    int a = 2;
    int b = 4;
    public void setData(int a, int b) {
        a = a;
        b = b;
    }
    public void showData() {
        System.out.println(a + " " + b);
    }
    public static void main(String args[]) {
        Array obj = new Array();
        obj.setData(2, 3);
        obj.setData(1, 3);
        obj.showData();
    }
}


1 3
2 3
2 4
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App