null
Jack
nullJack
运行时出现异常
第1题:
在编译Java程序时,用于指定生成.class文件位置的选项是()。
A.#NAME?
B.#NAME?
C.#NAME?
D.#NAME?
第2题:
给定如下Java程序代码片段,编译运行这段代码,结果是( )。
java.util.HashMapmap=newjava.util.HashMap();
map.put("name",null);
map.put("name","Jack");
System.out.println(map.get("name"));
A.null
B.Jack
C.nullJack
D.运行时出现异常
第3题:
执行以下代码后,下面哪些描述是正确的() public class Student{ private String name = “Jema”; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } public static void main(String[] args){ Student s; System.out.println(s.getName()); } }
第4题:
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println(super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()
第5题:
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); System.out.println(getName()); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()
第6题:
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println( super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()
第7题:
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?()
第8题:
smith,SALES
null,SALES
smith,null
null,null
编译错误
第9题:
0
null
false
编译错误
第10题:
smith
null
编译错误
name
第11题:
输出null
第10行编译报错
第11行编译报错
输出Jema
第12题:
0
null
false
编译错误
第13题:
给定java代码片段,如下:运行后,这段代码将输出()。

A.true
B.false
C.0
D.1
第14题:
试题六(共15分)
阅读以下说明、图和Java代码,填补Java代码中的空缺(1)~(6),将解答写在答题纸的
对应栏内。
【说明】
已知对某几何图形绘制工具进行类建模的结果如图6.1所示,其中Shape为抽象(abstract)类,表示通用图形,Box(矩形)、Ellipse(椭圆)和Line(线条)继承(extends)了Shape类,其中,Circle表示圆(即特殊的椭圆)。

下面的Java代码用于实现图 6-1所给出的设计思路,将其空缺处填充完整并编译运行,输出结果为:
Ellipse
Circle
Ellipse
C
E
【Java代码】
(1) class Shape{
public Shape(String name){
this.name= name;
}
(2) void paint();
String getName(){
retum this.name;
}
final String name;
};
//Box 和Line类似下面 Ellipse,其代码略
class Ellipse (3) {
public Ellipse(String name){
super(name);
System.out.println("Ellipse");
}
Void paintO{∥绘制现状示意代码
System.out.println(getName0);
}
};
class Circle (4) {
public Circle(String name){
super(name);
System.out.println("Circle");
}
};
class Diagram{
private Shape shapes[]= new Shape[2];
public void drawAShape(Shape shape){
shape.paint();
}
void erase A Shape(Shape shape){
∥删除形状,代码略
}
void drawShapes(){
shapes*0+= new Circle("C”);
shapes[l]= new Ellipse("E");
for (int i=O; i<2;++i) {
drawAShap(shapes[i]);//绘制形状
}
}
void close(){
for (int i=0;i<2; ++1) { []关闭图,删除所绘制图形
(5) ;
}
}
public static void main(String[] args){
Diagram diagram= (6) ;
diagram.drawShapes();
diagram.close();
}
}
第15题:
类Student代码如下: class Student{ String name; int age; Student(String nm){ name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()
第16题:
Assume a JavaBean com.example.GradedTestBean exists and has two attributes. The attribute name is oftype java.lang.String and the attribute score is of type java.lang.Integer. An array of com.example. GradedTestBean objects is exposed to the page in a request- scoped attribute called results. Additionally,an empty java.util.HashMap called resultMap is placed in the page scope. A JSP page needs to add the firstentry in results to resultMap, storing the name attribute of the bean as the key and the score attribute of thebean as the value. Which code snippet of JSTL code satisfies this requirement?()
第17题:
给定如下Java程序代码片段,编译运行这段代码,结果是()。 java.util.HashMap map=new java.util.HashMap(); map.put("name",null); map.put("name","Jack"); System.out.println(map.get("name"));
第18题:
现有: class A {public String name="a"} class B extends A {public String name="b"} 执行如下代码后的结果是哪项?() A a=new B(); System.out.println(a.name);
第19题:
类Student代码如下:D class Student{ String name; int age; Student(String nm){ (构造方法) name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()
第20题:
smith
null
SALES
编译错误
第21题:
smith,SALES
null,SALES
smith,null
null,null
第22题:
${resultMap[results[0].name] = results[0].score}
<c:set var=${resultMap} key=${results[0].name} value=${results[0].score} />
<c:set var=resultMap property=${results[0].name}> ${results[0].value}</c:set>
<c:set var=resultMap property=${results[0].name} value=${results[0].score} />
<c:set target=${resultMap} property=${results[0].name} value=${results[0].score} />
第23题:
a
b
编译失败
运行时抛出异常