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.
Disclaimer: All Simulation Exams practice tests, study guides and/or material are neither sponsored by, nor endorsed by, nor affiliated with Oracle® or any other company. All trademarks are trademarks of their respective owners and duly acknowledged. OCA™, OCPJP™, SCJP™ are registered trade marks of Oracle®. . The practice tests material is a copyright of SimulationExams.com and the same is not approved or endorsed by respective certifying bodies. Thank-you for your interest in Simulation Exams. Please see read me file before you download, install, and/or use any software from SimulationExams.com For any information or questions regarding this Website, please e-mail webmaster at simulationexams.com