Predict the output obtained on executing the given code.

class Main {
	public static void main(String args[]) {
		
		int x, y;
		x =2;
		y= 3;
		System.out.println(countt(y, x));
	}
	static int counter(int y, int x) {
		int count = 0;
		if (x == 1)
			return y;
		else {
			for (int i = 1; i <= y; i++) {
				for (int j = 1; j <= y; j++) {
					if (j % i == 0)
						count++;
				}
			}
		}
		return count;
	}
	static int countt(int y, int x) {
		if (x == 1)
			return y;
		if (x == 2) {
			return counter(y, x);
		}
		int mid = x / 2;
		int a = countt(y, x - mid);
		int b = counter(y, mid);
		return a + b - 1;
	}
}

5

4

7

No output

Verified Answer
Correct Option - a

To get all Infosys Certified Java SE11 Developer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in