Sim-Ex™ Practice Exams for Java SE 8 Programmer II: Sample Questions

Operators And Assignments

Home     Previous     Up    

Q10. What is the optput of this code fragment.


1. int X=3; int Y =10;

2. System.out.println(y%x);

A. 0

B. 1

C. 2

D. 3

Correct Answer: B

Explanation:

B is a correct answer. Dividing 10 by 3 gives 3 reminder 1, and this 1 forms the result of the modulo expression. Same rule applies for the negative numbers, you should ignore the signs during calculation part, and simply attach the sign of the Left-hand operand to the result.

Home     Previous     Up    


Disclaimer: Simulationexams.com is not affiliated with any certification vendor, and Sim-Ex™ Practice Exams are written independently by SimulationExams.com and not affiliated or authorized by respective certification providers. Sim-Ex™ is a trade mark of SimulationExams.com or entity representing Simulationexams.com.SCJP® is a trademark of Oracle™.