这道题目的答案是不是有问题啊具体的题目是这样的:Consider the following java code: //in file Book.java package com.bookstore; public class Book { private String isbn; public Book(){ isbn = "UNDEFINED_BOOK"; } public S
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 11:22:53
这道题目的答案是不是有问题啊具体的题目是这样的:Consider the following java code: //in file Book.java package com.bookstore; public class Book { private String isbn; public Book(){ isbn = "UNDEFINED_BOOK"; } public S
这道题目的答案是不是有问题啊
具体的题目是这样的:
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的 大家都怎么认为啊? 高手能否为我讲解一下 谢谢啊!
可是这两个CLASS之间没有任何 关系啊~~~
这道题目的答案是不是有问题啊具体的题目是这样的:Consider the following java code: //in file Book.java package com.bookstore; public class Book { private String isbn; public Book(){ isbn = "UNDEFINED_BOOK"; } public S
下面是在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/jsp\pp_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()
赋值,很明显,这是错误的