Kevin Kilbane

Ranch Hand
+ Follow
since Sep 22, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kevin Kilbane

Pedro Kowalski wrote:@Kevin Yeah, it's correct but the Serializable is just a marker interface. By explicitly implementing it, you're saying that you are aware of the serializable restrictions and your class is prepared for it.

As Ulf said - if one of your sublcasses implements the Serializable interface, it doesn't necesary mean that your class IS SERIALIZABLE.
Be aware that in the above sentences the "IS SERIALIZABLE" should be understood as the class that can be serialized, and not as the class that implements (implicitly) the Serializable interface.



I understand your points but I don't agree!

A class is either Serializable or not - as far as the compiler or the JVM are concerned there is no such thing as implicit or explicit implementation of an interface.

if one of your sublcasses implements the Serializable interface, it doesn't necesary mean that your class IS SERIALIZABLE.


Yes it does! If your class is not Serializable then your code is wrong. If you extend a class that implements Serializable then you need to make sure your class is Serializable (you can mark elements as transient if needs be). If you don't, your program is wrong.

Ulf Dittmer wrote:It's perfectly possible for a subclass of a Serializable class not to be Serializable - by having a field that is not Serializable.



Incorrect. If a class implements an interface then all it's sub-classes also implement that interface.
Just to point out that many of the questions will tell you how many correct answers there are e.g. it will give 5 possible answers and say "select three" - in that scenario there should be no way that you get 3 correct and 1 wrong i.e. you will have selected 4 answers.

This is obviously a big help - as Sherlock Holmes points out "When you have eliminated the impossible, whatever remains, however improbable, must be the truth." - if there are 5 possible answers and you are told to select 3, if you find 2 answers that are definitely wrong then the other 3 are all correct.
Hi. I'm slightly confused by the pageContext implicit variable in a JSP.

What relationship does the PageContext object have with a JSP, a request etc.? Is there one PageContext object per JSP or one per execution of the JSP or something else?

There doesn't seem to be a PageContext object available in a servlet - is that right?

I've had a look at the API and a search in google but I'm still not 100% clear.

Thanks in advance.
Thanks for the response. That was one of the solutions I had seen previously.

Does the <resource-ref> entry in the web.xml file not allow us to specify the JNDI name?

Why does JBoss require the an app-server specific config file when other servers do not?
14 years ago
Hi,

Warning: newbie question ahead.

I'm having problems trying to set up JNDI DataSources in JBoss 5.1.0. A lot of the solutions to similar issues refer to the jboss-web.xml file in the WEB-INF directory of the WAR file. Could someone explain to me why this file exists and what it's purpose is? What does it provide that a normal web.xml does not?

Thanks.
14 years ago
yep Mark, you are right - see my edited post and my 3 rules for determining the generic type. does that sound right to you?

Mark Moge wrote:Ok I was wrong. And after some thinking ... in my opinion it works like this: if you have a generic declaration of a method

T from a metod works as T extends superclass of all arguments in method.
So you can put any type as argument:



Excellent question by the way.

I don't know the answer definitively but I think this is how it works. When more than one argument is passed to a method that defines a generic type then the compiler does the following checks:

1. If the arguments are all of the same type then the compiler treats T as that type e.g. if all arguments are Strings then T is treated as a String. Simple.

2. If the arguments are of different types but are in the same class hierarchy then the compiler treats T as the highest in the hierarchy e.g. if the arguments are of types Integer and Number then T is treated as Number.

3. If the arguments are of different types and are NOT in the same class hierarchy then the compiler treats T as Object e.g. if the arguments are of types Integer and String then T is treated as Object by the compiler.

See below:



Note: edited since first posted
V Aravind - your question is unclear, can you post some code?

just to elaborate on what phil sohar said (if this is what you are asking)



Yep, at least one second. There might only be one thread in your program but the JVM is doing other stuff e.g. garbage collection. Also, the machine your JVM is running on will be doing other stuff, the JVM isn't the only thing running on your computer's processor!

Ireneusz Kordal wrote:change line 25 to:



yep:



moral of the story: you're better off always using .equals when comparing Strings.

Bert Bates wrote:Hi Guys,

The wait() and notify() topics are good topics, but they've been removed from the SCJP exam.

hth,

Bert


They are not in SCJP6 but are still in SCJP5 - correct?

Henry Wong wrote:
"IS-A relationship" is the ability of an object of one class type to behave as another class type. Just because you are able to form an english sentence with "is" followed by "a", doesn't mean that there is a "IS-A" relationship involved.

Henry



Sorry, did some further checking after I posted the last reply. The Bates and Sierra book states in Chapter 2 (top p.95 in my copy):

"Other than objects of type Object, all Java objects are polymorphic in that they pass the IS-A test for their own type and for class Object."

The important bit here is "they pass the IS-A test for their own type" i.e. String IS-A String.

I'm still leaning towards thinking the answers in MasterExam are wrong.

Henry Wong wrote:
"IS-A relationship" is the ability of an object of one class type to behave as another class type. Just because you are able to form an english sentence with "is" followed by "a", doesn't mean that there is a "IS-A" relationship involved.

Henry



Thnaks for the prompt reply Henry.

Have a look at this method:


Statement 1: "The parameter to the doStuff method must be an object that passes the IS-A Car test".

Statement 2: "The parameter to the doStuff method must be a Car object or an object that passes the IS-A Car test".

I always thought statement 1 was correct but you are saying that statement 1 is incorrect and statement 2 is correct.

Is that right?