What is the result if the integer aVar is 9?

Given the code fragment:

What is the result if the integer aVar is 9?

Given the code fragment:

What is the result if the integer aVar is 9?

A.
Compilation fails.

B.
10 Hello Universe!

C.
10 Hello World!

D.
9 Hello World!



Leave a Reply 9

Your email address will not be published. Required fields are marked *


leoromerbric

leoromerbric

B

Sucuk

Sucuk

Wrongism, it’s Hello World. Arigato Gozeymas

v10

v10

correct answer is C “10 Hello World!”

Sucuk

Sucuk

I don’t think so bro. It will print 9 hello world first because its post increment

Sucuk

Sucuk

I just did a test and you’re right > its D.

Sucuk

Sucuk

I mean C!!!!!

renko

renko

Answer: C

package q035;

public class Test {

public static void main(String[] args) {
int aVar = 9;

if (aVar++ < 10) {
System.out.println(aVar + " Hello World!");
} else {
System.out.println(aVar + " Hello Universe");
}

}

}
Output:
10 Hello World!