题目
题目

CSE-110-OD25-27 3.1: Lesson and Knowledge Check - Study Hall Video Episode 3

单项选择题

Which of the following correctly exemplifies a Java expression for copying a variable?

选项
A.double numberOfBooks = 10.5; int numberOfStudents; numberOfStudents = numberOfBooks;
B.int numberOfBooks; int numberOfStudents; numberOfBooks = numberOfStudents;
C.int numberOfBooks; int numberOfStudents = 5;
D.int numberOfBooks; int numberOfStudents;
查看解析

查看解析

标准答案
Please login to view
思路分析
Let’s break down what each option is doing in terms of Java syntax and variable initialization. Option A: double numberOfBooks = 10.5; int numberOfStudents; numberOfStudents = numberOfBooks; - Here, numberOfBooks is a double and numberOfStudents is an int. Assigning a double to an int requires an explicit cast in Java; without a cast, this assignment is a type mismatch error. So this......Login to view full explanation

登录即可查看完整答案

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

更多留学生实用工具

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