题目
这道题目的答案是不是有问题啊
具体的题目是这样的:
Consider the following java code:
//in file Book.java
package com.bookstore;
public class Book
{
private String isbn;
public Book(){ isbn = "UNDEFINED_BOOK"; }
public String getIsbn(){ return isbn; }
public void setIsbn(String value){ this.isbn = value; }
}
//in file MusicCD.java
package com.bookstore;
public class MusicCD
{
private String isbn;
public MusicCD(){ isbn = "UNDEFINED_CD"; }
public String getIsbn(){ return isbn; }
public void setIsbn(String value){ this.isbn = value; }
}
Code for browse.jsp:
What is printed in the generated response of browse.jsp?
Select 1 correct option.
a.UNDEFINED_BOOK
b.UNDEFINED_CD
c.It will not compile
d.It will compile but will give an exception at request time.
它的答案说是选C 说不会通过编译的 可是我个人感觉应该是选D的 会通过编译只是会抛出ClassCastException的 大家都怎么认为
具体的题目是这样的:
Consider the following java code:
//in file Book.java
package com.bookstore;
public class Book
{
private String isbn;
public Book(){ isbn = "UNDEFINED_BOOK"; }
public String getIsbn(){ return isbn; }
public void setIsbn(String value){ this.isbn = value; }
}
//in file MusicCD.java
package com.bookstore;
public class MusicCD
{
private String isbn;
public MusicCD(){ isbn = "UNDEFINED_CD"; }
public String getIsbn(){ return isbn; }
public void setIsbn(String value){ this.isbn = value; }
}
Code for browse.jsp:
What is printed in the generated response of browse.jsp?
Select 1 correct option.
a.UNDEFINED_BOOK
b.UNDEFINED_CD
c.It will not compile
d.It will compile but will give an exception at request time.
它的答案说是选C 说不会通过编译的 可是我个人感觉应该是选D的 会通过编译只是会抛出ClassCastException的 大家都怎么认为
提问时间:2021-04-02
答案
下面是在tomcat下运行后的错误显示:
org.apache.jasper.JasperException:Unable to compile class for JSP:
JSP FileName:/pp.jsp
Java FileName:/D:/Tomcat5.5/work/Catalina/localhost/test//org/apache/jsppp_jsp.java
An error occurred at line:14 in the jsp file:/pp.jsp
Type mismatch:cannot convert from Book to MusicCD
11:
12:
13:
14:
15:
16:asdfasdfasdfasdfasdfsadf
17:
所以确实是无法编译的,至于原因,是因为这两个类没有任何联系,想通过Book bookorcd= new MusicCD()
赋值,很明显,这是错误的
org.apache.jasper.JasperException:Unable to compile class for JSP:
JSP FileName:/pp.jsp
Java FileName:/D:/Tomcat5.5/work/Catalina/localhost/test//org/apache/jsppp_jsp.java
An error occurred at line:14 in the jsp file:/pp.jsp
Type mismatch:cannot convert from Book to MusicCD
11:
12:
13:
14:
15:
16:asdfasdfasdfasdfasdfsadf
17:
所以确实是无法编译的,至于原因,是因为这两个类没有任何联系,想通过Book bookorcd= new MusicCD()
赋值,很明显,这是错误的
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
热门考点
- 1有一块长方形菜园,如果长增加6米,刚面积增加6米,如果宽增加6米,则面积增加180平方米,菜园原来面积是多少
- 2超级惊喜翻译成英文
- 3过抛物线Y^2=4x的焦点做一条直线与抛物线相交于A、B两点,它们的横坐标之和等于5,则这样的直线有几条
- 41.My books are on the table.的问句
- 5已知f(x)是定义的R上的偶函数,并满足f(x+2)=-1/f(x),当1小于等于x
- 6Li Lei is ten years old and Mike is also ten years old.(改为同义句)
- 7某部队派出一支有25人组织的小分队参加防汛抗洪斗争,若每人每小时可装泥土18袋或每2人每小时可抬泥土14袋,如何安排好人力,才能使装泥和抬泥密切配合,而正好清场干净.
- 8如何指导孩子写 开学第一天的日记
- 9抗体上与抗原决定簇结合的部位是什么
- 10孔子犹江海可以看出孔子身上有怎样的精神品质?