每日10道JAVA题(20180612)

/**
 * 10道题系列会持续更新,每日的10道题都是我做过的,做错或者觉得需要复习的有价值的
 * 请关注我,每日和我一同进步,有更好的建议或有问题的请在评论区提出或私信我
 */

1.class A {}

class B extends A {}
class C extends A {}
class D extends B {}
Which four statements are true ?


A.The type List<A>is assignable to List.
B.The type List<B>is assignable to List<A>.
C.The type List<Object>is assignable to List<?>.
D.The type List<D>is assignable to List<?extends B>.
E.The type List<?extends A>is assignable to List<A>.
F.The type List<Object>is assignable to any List reference.
G.The type List<?extends B>is assignable to List<?extends A>.


2.已知有下列Test类的说明,则下列哪个语句是正确的?()
public class Test
{
private float f = 1.0f;
int m = 12;
static int n = 1;
public static void main (String args[])
{
Test t = new Test();
}
}


A.t.f;
B.this.n;
C.Test.m
D.Test.f


3.判断对错。List,Set,Map都继承自继承Collection接口。


A.对
B.错


4.阅读下列程序,选择哪一个是正确的输出结果


class HelloA{
public HelloA()
    {
        System.out.println("I’m A class ");
    }
    static
    {
    System.out.println("static A");
    }
}
public class HelloB extends HelloA{
    public HelloB()
    {
        System.out.println("I’m B class");
    }
    static{
        System.out.println("static B");
    }
    public static void main (String[] args){
        new HelloB();
    }
}


A.static A I’m A class static B I’m B class
B.I’m A class I’m B class static A static B
C.static A static B I’m A class I’m B class
D.I’m A class static A I’m B class static B


5.下面关于Spring的说法中错误的是()


A.Spring是一系列轻量级Java EE框架的集合
B.Spring中包含一个“依赖注入”模式的实现
C.使用Spring可以实现声明式事务
D.Spring提供了AOP方式的日志系统


6.如何获取ServletContext设置的参数值?


A.context.getParameter()
B.context.getInitParameter()
C.context.getAttribute()
D.context.getRequestDispatcher()


7.A 是抽象父类或接口, B , C 派生自 A ,或实现 A ,现在 Java 源代码中有如下声明:


1. A  a0=new  A();
2. A  a1 =new  B();
3. A  a2=new  C();


问以下哪个说法是正确的?( )


A.第1行不能通过编译
B.第1、2行能通过编译,但第3行编译出错
C.第1、2、3行能通过编译,但第2、3行运行时出错
D.第1行、第2行和第3行的声明都是正确的


8.检查程序,是否存在问题,如果存在指出问题所在,如果不存在,说明输出结果。


package algorithms.com.guan.javajicu; 
public class Inc { 
    public static void main(String[] args) { 
       Inc inc = new Inc(); 
       int i = 0; 
       inc.fermin(i); 
       i= i ++; 
       System.out.println(i);
    
    } 
    void fermin(int i){ 
       i++; 
    } 
}


A.0
B.1
C.2
D.3


9.
Integer i = 42;
Long l = 42l;
Double d = 42.0;
下面为true的是
正确答案: G   你的答案: A D E F G (错误)
A.(i == l)
B.(i == d)
C.(l == d)
D.i.equals(d)
E.d.equals(l)
F.i.equals(l)
G.l.equals(42L)


10.代码System. out. println(10 % 3 * 2);将打印出?
A.1
B.2
C.4

D.6

答案


猜你喜欢

转载自blog.csdn.net/stridebin/article/details/80664780