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