* 10道题系列会持续更新,每日的10道题都是我做过的,做错或者觉得需要复习的有价值的
*请关注我,每日和我一同进步,有更好的建议或有问题的请在评论区提出或私信我
复习
1.对于以下代码段,4个输出语句中输出true的个数是( )。
class A{}
class B extends A{}
class C extends A{}
class D extends B{}
A obj = new D();
System.out.println(obj instanceof B);
System.out.println(obj instanceof C);
System.out.println(obj instanceof D);
System.out.println(obj instanceof A);
A.1
B.2
C.3
D.4
2.以下哪个不属于JVM堆内存中的区域()?
A.survivor区
B.常量池
C.eden区
D.old区
3.关于下面的程序Test.java说法正确的是( )。
public class Test {
static String x="1";
static int y=1;
public static void main(String args[]) {
static int z=2;
System.out.println(x+y+z);
}
}
A.3
B.112
C.13
D.程序有编译错误
4.关于JAVA堆,下面说法错误的是()?
A.所有类的实例和数组都是在堆上分配内存的
B.堆内存由存活和死亡的对象,空闲碎片区组成
C.数组是分配在栈中的
D.对象所占的堆内存是由自动内存管理系统回收
5.哪个类可用于处理 Unicode?
A.InputStreamReader
B.BufferedReader
C.Writer
D.PipedInputStream
6.
class A{
public A foo(){return this;}
}
class B extends A{
public A foo(){
return this;
}
}
class C extends B
{
_______
}
可以放入到横线位置,使程序正确编译运行,而且不产生错误的选项是( )
A.public void foo(){}
B.public int foo(){return 1;}
C.public A foo(B b){return b;}
D.public A foo(){return A;}
7.
What will be printed when you execute the following code?
class C {
C() {
System.out.print("C");
}
}
class A {
C c = new C();
A() {
this("A");
System.out.print("A");
}
A(String s) {
System.out.print(s);
}
}
class Test extends A {
Test() {
super("B");
System.out.print("B");
}
public static void main(String[] args) {
new Test();
}
}
A.BB
B.CBB
C.BAB
D.None of the above
8.void waitForSignal()
{
Object obj = new Object();
synchronized(Thread.currentThread())
{
obj.wait();
obj.notify();
}
}
Which statement is true?
A.This code may throw an InterruptedException
B.This code may throw an IllegalStateException
C.This code may throw a TimeOutException after ten minutes
D.This code will not compile unless”obj.wait()”is replaced with”(Thread)obj).wait()”
E.Reversing the order of obj.wait()and obj.notify()may cause this method to complete normally
9.public class B
{
public static B t1 = new B();
public static B t2 = new B();
{
System.out.println("构造块");
}
static
{
System.out.println("静态块");
}
public static void main(String[] args)
{
B t = new B();
}
}
A.静态块 构造块 构造块 构造块
B.构造块 静态块 构造块 构造块
C.构造块 构造块 静态块 构造块
D.构造块 构造块 构造块 静态块
10.
如何获取ServletContext设置的参数值?
A.context.getParameter()
B.context.getInitParameter()
C.context.getAttribute()
D.context.getRequestDispatcher()