java章节练习题_java 1-6章测试题.doc

java 1-6章测试题

Java 1-6章测试题

选择题

1.public static void main(String args[]) {

boolean a[]=new boolean[4];

int I= 1;

System.out.println(a[I]);

}

What will be printed?()

A:Compilation Error in Line 2

B:Compilation Error in line 4

C:Exception in Line 4

D:Will print true

E:Will print false√

F:Will print null

2.public class A{

public static void main(String args[]) {

Integer b= new Integer(10);

Add(b);//静态方法里无法调用非静态方法

System.out.println(value());

}

void Add(Integer b){

int I= value();

I+=3;

b= new Integer(I);

}

What will be printed out?

A.Will print 13

B.Will print 10

C.Compilation Error in Line 4 ?. implicit conversion to Integer to

String is not possible

D.Compilation Error in line 10 you can't re initialize a Wrapper

Class Exception in Line 10

3. public static void main(String args[])

{

Float f=new Float(4.2f);

Float c;

Double d=new Double(4.2);

float fl=4.2f;

c=f;

}

which will return true?.

A. Select all

B.f.equls(d)

C.c==f

D.c==d

E.c.equls(f)

4. public static void main(String args[])

{

String s;

System.out.println("s = "+s);

}

what will be printed out?

A:Compilation Error

B:An Exception will occur

C:Will print s= null

D:Will print s=

5. class sree

{

fun(){

static int I =0;

I++;

}

public static void main(String args[])

{

sree obj=new sree();

obj.fun();

obj.fun();

}

what will be the value of I ?

A. Compilation error

B. Run time Error

C. 1

D. 2

6. which are the correct forms of Overloading Constructors for the

class hai?

A.public void hai(int a)

B.hai(int a,int b)

C.public hai(int a)

D.int hai(int c, int d)

E.int hai()

F.int hai(String s)

7. Which are the correct forms of overriding for the method void hai(int

a,int b)

A.public void hai(int a,int b)

B.protected void hai(int a,int b)

C.public hai(int a)

D.int hai(int c, int d)

E.int Hai()

F.int hai(String s)

8. public static void main(String args[])

{

int a=10;

int b=20;

if(a=b)

System.out.println("Not Equal");

else

System.out.println("Equal");

}

What will be the output?

A. Equal

B. Not Equal

C. Compilation Error

D. An Exception will

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值