Dave Walsh

Greenhorn
+ Follow
since Jun 21, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dave Walsh

Now I feel I must know the whole Exception tree hierarchy to pass the exam. Fantastic.
Having main() throw an exception is not a good practice, incidently because no one can catch the exception but it certainly is legal. Any method can throw exceptions, main() included. If main() throws an exception, the program stops.

Originally posted by marcelo ribeiro:
Hello,

I'm thinking about to buy Whizlabs SCJP 5.0 Training, I would like to hear opnion about these mocks exams.

Thanks in advance



Yeah and is the claimed success rate (99.7%) plausible to you ?

Originally posted by Pradeep Kumar Meruva:
Hi gitesh,

You will get the run time expection at \\3 and \\4 .

thanks,
pradeep,
SCJP1.4



//3 is obviously not a valid number for a short. Here's the explanation for //4 exception, from the API: "The string is converted to a short value in exactly the manner used by the parseShort method for radix 10".

Such details drive me nuts !!!

Originally posted by septimiu pelau:
Hi there

the first chapter's two-minute drill (SCJP5, page 69) states at Interface Implementation, bullet #2:

"Interfaces can be implemented by any class, from any inheritance tree."

I think this is correct only if interfaces are declared as public. You can have a default interface as well, which is not visible by a class from a different package.

Am I right?

thanks,
Septimiu


Yes. You have to take access privileges into account.

Originally posted by Burkhard Hassel:
Name clash.

See this thread:
https://coderanch.com/t/263763/java-programmer-SCJP/certification/Generics


Yours,
Bu.



Are you serious ? It's not an overriding method IS-A parameter problem ?
Because Object can only be a super class of <E>, being the superclass of any java object. Hence, overriding methods can only have parameters that pass the IS-A test with the superclass parameters. In that case, Object doesn't pass the test, whatever is E.

PS: I'll bet someone will soon ask you to change your display name for your real name !
It's because Derived's unimplemented default constructor calls Base's contrusctor, which calls amethod() but at runtime, polymorphism comes into play and and the call is transfered to Derived's amethod().
I'm almost 100% sure you can't. Give it a try !

Originally posted by Jesper Young:
About the static method: The error message that the compiler gives you is indeed strange, because static methods cannot be overridden.

According to the Java Language Specification section 8.4.8, a static method can hide (but not override) other static methods in superclasses.

The fact that you get an error is correct; in section 8.4.8.3 the JLS says:

"A method declaration must not have a throws clause that conflicts (�8.4.6) with that of any method that it overrides or hides; otherwise, a compile-time error occurs."

It's just the wording of the error message from the compiler that's incorrect - it should have said "fun() in B cannot hide fun() in A" instead of "override".

The Java compiler isn't perfect, it's also just a piece of software written by a human being...



K&B use the word redefine instead of hide. I like it better.
Have you tried it ? It doesn't compile: "Imports (if any) must come after package and before class definition".

Who told you the output is 8 ?
Wild guessing here, I haven't even tried it (too lazy ). I'm putting my java intuition to the test.

Could it be an assignment matter ? On line 1, the compiler can see that the value, although an int literal, holds in a byte (less than 127). So no casting needeed When you pass a parameter to a function, it's a type problem. All the compiler cares about is that types are compatible and in that case, you must downcast an int to a byte.

Please correct me if required !

Originally posted by partho mukherjee:
see the code snippet below

public class Horse extends Animal {
private Halter myHalter;
public void tie(LeadRope rope) {
myHalter.tie(rope); // Delegate tie behavior to the
// Halter object
}
}
public class Halter {
public void tie(LeadRope aRope) {
// Do the actual tie work here
}
}

this code confuses me as the Halter object has never been instantiated and so it quite evidently gives null pointer exception when I invove the method
tie() of Horse class. Am I missing out on something? This I have taken from K & B chapter 2.



You just answered your own question: instantiate it somewhere !
private Halter myHalter = new Halter();
All this is fascinating...

Didn't I read somewhere that shifting operators are not on the exam ?

Originally posted by Burkhard Hassel:
Howdy ranchers

You can read it 100 times and still fail.

It does not matter how often you read it, only you should know everything that the book contains. You have to do a lot of mock tests to know how much you understand.


Yours,
Bu.



Yeah that's the feeling I get. This stuff is not too hard to understand. The toughest is to remember everything: rules, APIs, subtleties, etc.

That's why I don't agree with K&B authors: doing lots of small programs help understanding the basic stuff. But there's no way one could think of all possible tricky scenarios regarding one rule or one set of API by himself. In other words, coding won't make you pass the exam. Tough mock questions will.

So here's what I plan to do:

1- Read the book and underline anything I need to remember
2- Reread what I underlined + 2 minutes drill
3- Take tons of mock exams (Enthuware + Whizlabs: yeah that's 100$+ extra)
4- Spend time everyday reading/replying in this forum, which is also an excellent source of tricky scenarios

What do you guys think ?

D.