150k views
5 votes
What will be the output?
System.out.println( 9/4 + " with remainder " + 9%4);

1 Answer

3 votes

Answer:

2 with remainder 1

Step-by-step explanation:

Since you're performing integer arithmetic, 9/4 evaluates to 2 and 9%4 is the remainder. 9 = 2*4+1.

System.out.println( 9/4 + " with remainder " + 9%4);

You can easily run little java programs yourself online at replit if you don't want to install the java compiler.

User Maugch
by
4.8k points