网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
给定如下Java程序代码片段,编译运行这段代码,结果是()。 java.util.HashMap map=new java.util.HashMap(); map.put("name",null); map.put("name","Jack"); System.out.println(map.get("name"));
A
null
B
Jack
C
nullJack
D
运行时出现异常
参考答案
参考解析
解析:
暂无解析
更多 “单选题给定如下Java程序代码片段,编译运行这段代码,结果是()。 java.util.HashMap map=new java.util.HashMap(); map.put("name",null); map.put("name","Jack"); System.out.println(map.get("name"));A nullB JackC nullJackD 运行时出现异常” 相关考题
考题
【Java代码】import Java.util.ArrayList;import java.util.List;(1) class AbstractFile{protected String name;public void printName(){System.out.println(name);}public abstract boolean addChild(AbstractFile file);public abstract boolean removeChild(AbstractF ile file);public abstract ListAbstractFile getChildren();}class File extends AbstractFile{public File(String name){this.name=name;}public boolean addChild(AbstractFile file){return false;}public boolean removeChild(AbstractFile file){return false;}public ListAbstractFile getChildren(){return (2) ;}}class Folder extends AbstractFile{private List AbslractFile childList;public Folder(String name){this.name=name;this.childList=new ArrayListAbstractFile();}public boolean addChild(AbstractFile file) { return childList.add(file);}public boolean removeChild(AbstractFile file){return childList.remove(file);}public (3) AbstractFile getChildren(){return (4) ;}}public class Client{public static void main(String[] args){//构造一个树形的文件/目录结构AbstractFile rootFolder= new Folder("c:\\ ");AbstractFile compositeFolder=new Folder("composite");AbstractFile windowsFolder=new Folder("windows");AbstractFile file=new File("TestComposite.java");rootFolder.addChild(compositeFolder) ;rootFolder.addChild(windowsFolder);compositeFolder.addChild(file) ;//打印目录文件树printTree(rootFolder);}private static void printTree(AbslractFile ifile){ifile.printName();List AbslractFile children=ifile.getChildreno:if(children==null) return;for (AbstractFile file:children) {(5) ;}}}该程序运行后输出结果为:c:\compositeTestComposite.javaWindows
考题
执行以下代码后,下面哪些描述是正确的()publicclassStudent{privateStringname=Jema”;publicvoidsetName(Stringname){this.name=name;}publicStringgetName(){returnthis.name;}publicstaticvoidmain(String[]args){Students;System.out.println(s.getName());}}A.输出nullB.第10行编译报错C.第11行编译报错D.输出Jema
考题
查找条件为:姓名不是NULL的记录( )A.WHERE NAME ! NULLB.WHERE NAME NOT NULLC.WHERE NAME IS NOT NULLD.WHERE NAME!=NULL
考题
现有:classA{publicStringname=a}classBextendsA{publicStringname=b}执行如下代码后的结果是哪项?()Aa=newB();System.out.println(a.name);
A.aB.bC.编译失败D.运行时抛出异常
考题
给定如下Java程序代码片段,编译运行这段代码,结果是( )。java.util.HashMapmap=newjava.util.HashMap();map.put("name",null);map.put("name","Jack");System.out.println(map.get("name"));A.nullB.JackC.nullJackD.运行时出现异常
考题
试题六(共15分)阅读以下说明、图和Java代码,填补Java代码中的空缺(1)~(6),将解答写在答题纸的对应栏内。【说明】已知对某几何图形绘制工具进行类建模的结果如图6.1所示,其中Shape为抽象(abstract)类,表示通用图形,Box(矩形)、Ellipse(椭圆)和Line(线条)继承(extends)了Shape类,其中,Circle表示圆(即特殊的椭圆)。下面的Java代码用于实现图 6-1所给出的设计思路,将其空缺处填充完整并编译运行,输出结果为:EllipseCircleEllipseCE【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; i2;++i) {drawAShap(shapes[i]);//绘制形状}}void close(){for (int i=0;i2; ++1) { []关闭图,删除所绘制图形(5) ;}}public static void main(String[] args){Diagram diagram= (6) ;diagram.drawShapes();diagram.close();}}
考题
执行以下代码后,下面哪些描述是正确的() 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()); } }A、输出nullB、第10行编译报错C、第11行编译报错D、输出Jema
考题
类Student代码如下: class Student{ String name; int age; Student(String nm){ name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?() A、 0B、 nullC、 falseD、 编译错误
考题
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”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,nullE、 编译错误
考题
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?()A、${resultMap[results[0].name] = results[0].score}B、c:set var="${resultMap}" key="${results[0].name}" value="${results[0].score}" /C、c:set var="resultMap" property="${results[0].name}" ${results[0].value}/c:setD、c:set var="resultMap" property="${results[0].name}" value="${results[0].score}" /E、c:set target="${resultMap}" property="${results[0].name}" value="${results[0].score}" /
考题
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”)后程序的输出是哪项?() A、 smithB、 nullC、 SALESD、 编译错误
考题
给定如下Java程序代码片段,编译运行这段代码,结果是()。 java.util.HashMap map=new java.util.HashMap(); map.put("name",null); map.put("name","Jack"); System.out.println(map.get("name"));A、nullB、JackC、nullJackD、运行时出现异常
考题
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”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,null
考题
现有: class A {public String name="a"} class B extends A {public String name="b"} 执行如下代码后的结果是哪项?() A a=new B(); System.out.println(a.name); A、 aB、 bC、编译失败D、运行时抛出异常
考题
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”)后程序的输出是哪项?() A、 smithB、 nullC、 编译错误D、 name
考题
类Student代码如下:D class Student{ String name; int age; Student(String nm){ (构造方法) name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()A、 0B、 nullC、 falseD、 编译错误
考题
单选题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”)后程序的输出是哪项?()A
smith,SALESB
null,SALESC
smith,nullD
null,nullE
编译错误
考题
单选题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”)后程序的输出是哪项?()A
smithB
nullC
SALESD
编译错误
考题
单选题类Student代码如下: class Student{ String name; int age; Student(String nm){ name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()A
0B
nullC
falseD
编译错误
考题
单选题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”)后程序的输出是哪项?()A
smith,SALESB
null,SALESC
smith,nullD
null,null
考题
单选题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”)后程序的输出是哪项?()A
smithB
nullC
编译错误D
name
考题
单选题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?()A
${resultMap[results[0].name] = results[0].score}B
c:set var=${resultMap} key=${results[0].name} value=${results[0].score} /C
c:set var=resultMap property=${results[0].name} ${results[0].value}/c:setD
c:set var=resultMap property=${results[0].name} value=${results[0].score} /E
c:set target=${resultMap} property=${results[0].name} value=${results[0].score} /
考题
单选题执行以下代码后,下面哪些描述是正确的() 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()); } }A
输出nullB
第10行编译报错C
第11行编译报错D
输出Jema
考题
单选题现有: class A {public String name="a"} class B extends A {public String name="b"} 执行如下代码后的结果是哪项?() A a=new B(); System.out.println(a.name);A
aB
bC
编译失败D
运行时抛出异常
考题
单选题类Student代码如下:D class Student{ String name; int age; Student(String nm){ (构造方法) name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()A
0B
nullC
falseD
编译错误
热门标签
最新试卷