帮忙做个java程序题目
1) 在JAVA编程中,以下( b )命令用来执行java类文件。
a) javac
b) java
c) appletviewer
d) 以上所有选项都不正确
2) MyProgram.Java被编译后,生成( )。
a) MyProgram. Obj
b) MyProgram. class
c) MyProgram.exe
d) MyProgram. bat
3) 编译、运行下面代码将发生什么?
public class Test5 {
public static void main (String args []) {
/* This is the start of a comment
System.out.println("Done the test");
/* This is another comment */
System.out.println ("The end");
}
}
a) 程序运行出错。
b) 输出“Done the test”。
c) 输出“The end”。
d) 输出“Done the test”和“The end”。
4) 请问下面哪些代码行编译时会出错?
a) float f = 1.3;
b) double D=4096.0;
c) boolean b = null;
d) String s = "1";
e) int i = 10;
f) char c = "a";
5) 如果定义有double x;float y;int m,则表达式x*y-m的类型为( ):
a) double
b) float
c) int
d) short
6) 如果int a=3,b=2,则执行a*=b+8后a的值为:( )
a) 20
b) 14
c) 30
d) 16
7) 下面的逻辑表达式中合法的是__________
a) (7+8)&&(9-5)
b) (9*5)||(9*7)
c) 9>6&&8<10
d) (9%4)&&(8*3)
8) 下面代码段的运行结果是()
int i = 3;
int j = 0;
double k = 3.2;
if (i < k)
if (i == j)
System.out.println(i);
else
System.out.println(j);
else
System.out.println(k);
a) 3
b) 0
c) 3.2
d) 以上三个都不对
9) 下面程序的执行结果是()
int i = 9;
switch (i) {
default:System.out.println("default");
case 0:System.out.println("zero");break;
case 1:System.out.println("one");
case 2:System.out.println("two");
}
a) default
b) default, zero
c) error default clause not defined
d) no output displayed
10) 下列语句序列执行后,k 的值是( )。
int i=4,j=5,k=9,m=5;
if(i>j||m<k) k++; else k--;
a) 5
b) 10
c) 8
d) 9
11) 若a和b均是整型变量并已正确赋值,正确的switch语句是( )。
a) switch(a+b); { ...... }
b) witch( a+b*3.0 ) { ...... }
c) switch a { ...... }
d) switch ( a%b ) { ...... }
12) 下列语句序列执行后,ch1 的值是( )。
char ch1=’A’,ch2=’W’;
if(ch1 + 2 < ch2 ) ++ch1;
a) ‘A’
b) ‘B’
c) ‘C’
d) B
13) 下列语句序列执行后,r 的值是( )。
char ch='8'; int r=10;
switch( ch+1 )
{
case '7': r=r+3;
case '8': r=r+5;
case '9': r=r+6; break;
default: r=r+8;
}
a) 13
b) 15
c) 16
d) 18
14) 下列方法定义中,正确的是。
a) void x( int a,int b ); { return (a-b); }
b) x( int a,int b) { return a-b; }
c) double x { return b; }
d) int x( int a,int b) { return a+b; }
15) 在某个类中存在一个方法:void getSort(int x),以下能作为这个方法的重载的声明的是。
a) public getSort(float x)
b) int getSort(int y)
c) double getSort(int x,int y)
d) void get(int x,int y)
答案:参考答案:
1) 在JAVA编程中,以下( b )命令用来执行java类文件。a) javac
b) java
c) appletviewer
d) 以上所有选项都不正确
2) MyProgram.Java被编译后,生成(b )。
a) MyProgram. Obj
b) MyProgram. class
c) MyProgram.exe
d) MyProgram. bat
3) 编译、运行下面代码将发生什么?(d
)
public class Test5 {
public static void main (String args []) {
/* This is the start of a comment
System.out.println("Done the test");
/* This is another comment */
System.out.println ("The end");
}
}
a) 程序运行出错。
b) 输出“Done the test”。
c) 输出“The end”。
d) 输出“Done the test”和“The end”。
4) 请问下面哪些代码行编译时会出错?a c f
a) float f = 1.3;
b) double D=4096.0;
c) boolean b = null;
d) String s = "1";
e) int i = 10;
f) char c = "a";
5) 如果定义有double x;float y;int m,则表达式x*y-m的类型为(a ):
a) double
b) float
c) int
d) short
6) 如果int a=3,b=2,则执行a*=b+8后a的值为:( c )
a) 20
b) 14
c) 30
d) 16
7) 下面的逻辑表达式中合法的是_____c_____
a) (7+8)&&(9-5)
b) (9*5)||(9*7)
c) 9>6&&8<10
d) (9%4)&&(8*3)
8) 下面代码段的运行结果是( b)
int i = 3;
int j = 0;
double k = 3.2;
if (i < k)
if (i == j)
System.out.println(i);
else
System.out.println(j);
else
System.out.println(k);
a) 3
b) 0
c) 3.2
d) 以上三个都不对
9) 下面程序的执行结果是(b)
int i = 9;
switch (i) {
default:System.out.println("default");
case 0:System.out.println("zero");break;
case 1:System.out.println("one");
case 2:System.out.println("two");
}
a) default
b) default, zero
c) error default clause not defined
d) no output displayed
10) 下列语句序列执行后,k 的值是(b )。
int i=4,j=5,k=9,m=5;
if(i>j||m<k) k++; else k--;
a) 5
b) 10
c) 8
d) 9
11) 若a和b均是整型变量并已正确赋值,正确的switch语句是(a )。
a) switch(a+b); { ...... }
b) witch( a+b*3.0 ) { ...... }
c) switch a { ...... }
d) switch ( a%b ) { ...... }
12) 下列语句序列执行后,ch1 的值是( d)。
char ch1=’A’,ch2=’W’;
if(ch1 + 2 < ch2 ) ++ch1;
a) ‘A’
b) ‘B’
c) ‘C’
d) B
13) 下列语句序列执行后,r 的值是( c)。
char ch='8'; int r=10;
switch( ch+1 )
{
case '7': r=r+3;
case '8': r=r+5;
case '9': r=r+6; break;
default: r=r+8;
}
a) 13
b) 15
c) 16
d) 18
14) 下列方法定义中,正确的是。D
a) void x( int a,int b ); { return (a-b); }
b) x( int a,int b) { return a-b; }
c) double x { return b; }
d) int x( int a,int b) { return a+b; }
15) 在某个类中存在一个方法:void getSort(int x),以下能作为这个方法的重载的声明的是。C
a) public getSort(float x)
b) int getSort(int y)
c) double getSort(int x,int y)
d) void get(int x,int y)
不同意上面的说法!手机游戏是java的一个分支写的j2me还有iangge分支是j2se它的基础非常强大!还有一个是j2ee一样厉害!java的运行不受平台的限制!只要有虚拟机就可以运行!所以灵活性强!但是速度没有C和C 快!所以大型软件还是采用C 来写!java的一个竞争对手就是C#是微软推出的!
上一个:麻烦问一下,北京的java培训怎么样啊?
下一个:JAVA类与对象相关编程