设有变量定义: short a = 300; 则以下哪一条语句会导致编译错误?
A: a += 3;
B: a = (short)a + 3;
C: a = (byte)(a + 3);
D: a = (short)(a * 100);
A: a += 3;
B: a = (short)a + 3;
C: a = (byte)(a + 3);
D: a = (short)(a * 100);
举一反三
- 【单选题】以下程序在编译时出现了错误,原因是()。 #include <stdio.h> void main () { int short,printF; printf(" 请输入一个数 "); scanf("%d",&short); printF=short/2 printf("%d %d", short,printF); } A. 声明语句有错, short 是关键字,不能用作变量名 B. 声明语句有错,不能用 printF 作为自定义变量名 C. 声明语句无错,不能用 scanf 向 short 变量输入值 D. 声明语句无错,不能用 printf 输出 short 变量
- 对于“switch(a)”表达式中的变量a,它可以被声明为哪些合法数据类型? A: boolean, byte, char, short, int, long B: boolean, byte, char, short, int C: byte, char, short, int D: boolean, byte, char, short, int, long, float, double
- 有以下方法的定义,请选择该方法的返回类型_________ method(byte x, double y) { return (short)x/y*2; } A: byte B: short C: int D: double
- 运行short s = 3; s+=2 ; 代码后,变量s的值是
- Short dialogue 3 A: In a bookstore. B: In a library. C: In a supermarket. D: In a restaurant.