java 选择_简单java选择

1、一个Java程序运行从上到下的环境次序是()A、操作系统、Java程序、JRE/JVM、硬件B、JRE/JVM、Java程序、硬件、操作系统C、Java程序、JRE/JVM、操作系统、硬件D、Java程序、操作系...

1、 一个Java程序运行从上到下的环境次序是( )

A、操作系统、Java程序、JRE/JVM、硬件

B、JRE/JVM、Java程序、硬件、操作系统

C、Java程序、JRE/JVM、操作系统、硬件

D、Java程序、操作系统、JRE/JVM、硬件

2、下面哪些是合法的标识符。( )

A、persons B、12345 C、 *point D、this

3、在java中定义常量的正确语法为:( )

A、int value=20; B、const int VALUE=20;

C、final int VALUE=20; D、int VALUE=20;

4、下面代码的运行输出结果是( )。

public class example

{

public static void main(String args[])

{

int X=0;

if (X>0) X=1;

switch(x)

{

case 1: System.out.println(1);

case 0: System.out.println(0);

case 2: System.out.println(2);

break;

case 3: System.out.println(3);

default:System.out.println(4);

break;

}

}

}

A 0 B 4 C 2 D 1

2 3 3 0

5、设有下列声明语句:

int i,j;

float x,y;

double u,v;

下列哪些赋值是合法的?( )

A.i=x; B.x=u+y; C.v=x D.y=j/i*x

6.在java中源代码编译后生成的文件的扩展名为:( )

A . class; B. java;

C. jsp; D. obj;

7、正确定义一个初始值为20的float类型的变量的语句是:( )

A float #value=20f; B float value#=20;

C float _value=20f; D float value=20;

8、下语句不能通过编译的是( )。

A. int[] a={1,2,3,4};

B. int b[];

C. int c[]=new int[3];

D. int d=new int[];

9、 已知类关系如下:

class Employee;

class Manager extends Employeer;

class Director extends Employee;

则以下关于数据的语句正确的是:( )。

A. Employee e=new Manager();

B. Director d=new Manager();

C. Director d=new Employee();

D. Manager m=new Director();

10、( )下面对类的申明哪个是正确的?

A)public class Fred {

public int x = 0;

public Fred (int x) {

this.x = x;

}

}

B)public class fred

public int x = 0;

public fred (int x) {

this.x = x;

}

}

C)public class Fred extends MyBaseClass, MyOtherBaseClass {

public int x = 0;

public Fred (int xval) {

x = xval;

}

}

D)protected class Fred {

private int x = 0;

private Fred (int xval) {

x = xval;

}

11、下面程序中类ClassDemo中定义了一个静态变量sum,分析程序段的输出结果。( )

class ClassDemo {

public static int sum=1;

public ClassDemo()

{sum=sum+5;}

}

class ClassDemoTest{

public static void main(String args[]) {

ClassDemo demo1=new ClassDemo();

ClassDemo demo2=new ClassDemo();

System.out.println(demo1.sum);

}

}

A、 0 B、 6 C、 11 D、 2

12、( )下面代码定义的接口中,方法MyMethod()的修饰属性为:

interface InterfaceDemo {

int MyMethod();

}

A、friendly B、public abstract

C、public static abstract D.protected

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值