Neil Mac

Greenhorn
+ Follow
since Oct 03, 2003
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 Neil Mac

Static blocks can't pass on any checked exceptions (i.e. throw them) - it must catch them or throw an unchecked exception.
An instance block can throw checked exceptions but they MUST be handled in EVERY constructor. But an instance block is probably of no use to you.
So, short answer..... you can't
20 years ago
The Mughal Java cert book I'm currently studying states that
"An instance initializer cannot make forward rererences to member varibles declared after the initializer"
However, the following code compiles and runs fine....
public class Driver{
{
att2 = false;
}
private boolean att2 = true;
...
...

The only difference I can see is that the book refers to Java 1.2 but the compiler I'm using is Java 1.4. Is this something that has changed ? Or am I missing something ludicrously simple here
Thanks.
20 years ago
The Mughal Java cert book I'm currently studying states that
"An instance initializer cannot make forward rererences to member varibles declared after the initializer"
However, the following code compiles and runs fine....
public class Driver{
{
att2 = false;
}
private boolean att2 = true;
...
...

The only difference I can see is that the book refers to Java 1.2 but the compiler I'm using is Java 1.4. Is this something that has changed ? Or am I missing something ludicrously simple here
Thanks.
20 years ago
Hi,
If I have classes Sub2 which inherits from Sub1 which in turn inherits from Super1 and each class defines the instance method someMethod() (i.e. Sub1 and Sub2 override the method)...
How can I access the top level class definition of someMethod() from Sub2 ?
I can't use super.someMethod() as that will invoke the method defined in Sub1 and I can't cast the 'this' reference as that only casts the reference type and has no bearing on which method is executed.
I'm going to stick my neck out here and say that it can't be done...
20 years ago
Ok, slightly grey area in my understanding of inheritance...
A class "SuperClass" has a sub-class "SubClass" and SuperClass defines a private method.
SubClass inherits this method (as it inherits all of the super class) but can't access it and no object of type SubClass can access this method through the SubClass interface.
How can we say that SubClass inherits this method if it knows nothing about it and can't access it ? What use is this ?
Hope you can help clear up my lack of understanding on this topic.
Thanks.
20 years ago
So, is it not an error (at compile or runtime) to extend Throwable as opposed to Exception ? I.e. the only difference will be that an exception which extends java.lang.Exception will be 'checked'.
The book was a little ambigous about this.
Thanks for your reply.
When creating a new exception type, should you extend java.lang.Throwable or java.lang.Exception.
The book I am using to study for my 1.4 cert states you should extend Exception, but then contradicts itself a few pages later.
Its not a massive issue you'll agree, but possibly one of these niggly things that could easily bite you on the ass in the exam.
Thanks.