aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JWebPlus exam question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JWebPlus exam question" Watch "JWebPlus exam question" New topic
Author

JWebPlus exam question

Milena Khlabystova
Greenhorn

Joined: Apr 26, 2001
Posts: 9
This question is from a practice test on the CD accompanying SCWCD Exam Study Kit:
-----------
Question ID :997972318804
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 AudioBook extends Book
{
private String isbn;
public AudioBook(){ isbn = "UNDEFINED_AUDIOBOOK"; }
public String getIsbn(){ return isbn; }
public void setIsbn(String value){ this.isbn = value; }
}
Code for browse.jsp:
<jsp:useBean class="com.bookstore.AudioBook" type="com.bookstore.Book" id="bookorcd" />
<jsp:getProperty name="bookorcd" property="isbn" />
What is printed in the generated response of browse.jsp?
-----------
Answers:
A. UNDEFINED_BOOK
B. UNDEFINED_AUDIOBOOK
C. It will not compile
D. It will compile but will give an exception at request time
-----------
The correct answer is supposedly B. But, the AudioBook class is declared in a file called MusicCD.java. So the compiler should complain that the class should be declared in AudioBook.java and, hence, the correct answer should be C.
The answer B would be correct if the class was declared in the file called AudioBook.java.
Am I right or am I missing something? Any thoughts?
Thanks!
Milena
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
Milena,
That must be a mistake as the second file will not even compile since there can only be one public class in a source file and that must match the name of the file.
Ignoring that comment, thought the out put will be b due to polymorphism.
- FK


The secret to creativity is knowing how to hide your sources.
Milena Khlabystova
Greenhorn

Joined: Apr 26, 2001
Posts: 9
This is precisely what I thought. Thanks for confirming.
Milena
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
You are welcome.
I saw a posting on JDiscuss that there had been some errors in JWebPlus and they are offering a new data bank download. I am not sure if you have to buy the full verion for that or if you can use it with the one that comes with the Study Kit.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JWebPlus exam question