![77a82afffca696db6f08414afcd7e664.png](https://img-blog.csdnimg.cn/img_convert/77a82afffca696db6f08414afcd7e664.png)
注意,题目有多选,也有单选。请认真作答。(感觉格式看的不舒服的朋友,可以下载word问文档)
1.在JAVA中,下列哪些说法是正确的(AC )
A. java源文件的扩展名为.java
B.写好的java源程序可以直接运行
c.编写的源程序必须先编译后才能运行
D.程序员可以读懂扩展名为.class的文件
2.下列标识符哪个是合法的(BD)
A. class
B. $abc
c. 1234
D. name
3.下面哪些赋值语句是正确的? (ABD )
A. long test = 012;
B. float f = -412;
c. int other = (int) true;
D. double d = 0x12345678;E. byte b = 128;
4.在Java 中,下列语句不能通过编译的有(BD)
A. string s= "join"+ 3;
B. int a= "join"+3;
c. int a= ,,a "+5;
D. float f=5+5.5;
5.设a = 3,则表达式(--a )<<a 的结果是(B )A. 16
B.8c.24D. 12
6.下列代码运行的结果是(C )
public static void main (string [] args) {
int x = 4 ;
int y = 5;
if(x++>4 &++y>5) {
x++;
}
system.out.println ( "x=" +x+ " , y=" +y);
}
A.x=4 , y=5
B. x=4,y=6
c. x=5, y=6
D. x=6,y=6
7.尝试运行下面的代码会发生什么?(B)
public class Test {
public static void main (string[] args) {
boolean m = true;
if (m = false) {
system.out.println ( "true") ;}else {
system.out.println ("false" );
}
}
}
A.输出字符串"true"B.输出字符串"false"c.编译时错误
D.运行时错误
8.编译并运行以下代码将发生什么?(E)
public static void main (string args [ ] ){
char digit = 'a ' ;
for (int i = o; i < 10; i++){
switch (digit)
{
case 'x':{
int j = 0;
system.out.println(j)
}
default :{
int j = 100;
system.out.println(j) ;
}
}
}
int i=j;
System. out. println(i) ;
}
A.输出11次100
B.输出10次100,然后抛出运行期异常
C.编译错误,因为变量i不能在main() 方法中被声明2次
D.编译错误,因为变量j不能在main() 方法中被声明2次
E.以上都不对
9. class Demo B
{
public static int fun(int c)
{
return C+=2;
}
public static void main (String[] args)
{
int temp = fun(2) ;
System. out. println (temp) ;
}
A.2
B.4
C. 6
D. 8
10.下面哪些函数是public void aMethod() {...}的重载函数?( BD)
A. void aMethod( ) {...}
B. public int aMethod(int a, float b) {...}
C. public void aMethod () {.. .}
D. public float aMethod (int m) { ..
11.在java中,关于数组描述正确的是(BD )
A.数组中的索引下标从1开始.
B.存储在数组当中的数据都属于同--数据类型
C.通过数组名. length ()能获得数组的长度
D.数组的最大索引下标是数组的长度减1
12.下面程序的输出结果是什么(D )
int[] arr = new int[10] ;
System. out.println(arr[0]) ;
A.编译不通过
B.运行时出错
C.输出null
D.输出0
13.下面哪个语句正确地声明一个整型的二维数组( CD)
A.inta[][]=newint[][];
B. int b[10] [10] = new int[][];
C. int c[] [] = new int[10] [10];
D. int []d[] = new int[10] [10];
14.以下代码输出是( D )
class Demo {
public static void main(String[] args) {
int i= 0;
int sum = 0;
while (i <= 10) {
i++;
if(i号2!=0)
continue;
sum+=i;
}
System. out. println (sum) ;
}
}
A.55
B. 45
C. 35
D.30
15.和下面代码能完成相同的选项是(B)
class Demo {
public static void main (String[] args) {
inti=1;
int sum = 0;
while (i <= 100) {
if(i%2==0){
sum=sum+i;
}
i++;
}
System. out. println (sum) ;
}
}
A.
for (int x =1; x<=100;x++) { sum=sum+x; }
B. for (int x =0; x<=100;x+=2) { sum=sum+x; }
C.
for (int x =1; X<=100;x+=2) { sum=sum+x; }
D..上述全对
16.下列有关类、对象和实例的叙述,正确的是哪一项? (D)
A.类就是对象,对象就是类,实例是对象的另一个名称,三者没有差别
B.对象是类的抽象,类是对象的具体化,实例是对象的另-一个名称
C.类是对象的抽象,对象是类的具体化,实例是类的另一-个名称
D.类是对象的抽象,对象是类的具体化,实例是对象的另-一个名称
17.下面关于java中包的说法正确的是(ACD )
A