题目
题目

CSE-110-OD25-27 5.1 Lesson and Knowledge Check - Study Hall Video Episodes 7-8

单项选择题

Which of the following is the correct code to perform the following tasks? ⦁ Print "The student has passed." if the integer variable finalMarks is greater than or equal to 50 ⦁ Print "The student has failed" if the variable finalMarks is less than 50

选项
A.if (finalMarks < 50) { System.out.println("The student has passed."); } else { System.out.println("The student has failed."); }
B.if (finalMarks == 50) { System.out.println("The student has passed."); } else { System.out.println("The student has failed."); }
C.for (finalMarks >= 50) { System.out.println("The student has passed."); } else { System.out.println("The student has failed."); }
D.if (finalMarks >= 50) { System.out.println("The student has passed."); } else { System.out.println("The student has failed."); }
查看解析

查看解析

标准答案
Please login to view
思路分析
To solve this, we must compare each option against the requirement: print "The student has passed." when finalMarks >= 50, otherwise print "The student has failed.". Option 1: if (finalMarks < 50) { System.out.println("The student has passed."); } else { System.out.println("The student has failed."); } This reverses the condition and the messages. It prints passed when finalMa......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!