Gaia Nathan

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

Recent posts by Gaia Nathan

Hi,
I have a query. Can assert statements be used in try-catch blocks ? If so, are there any special conditions ? Thanks in advance for replies.
Gaia.
20 years ago
Hi,
Like Jawahar, I'm also a newbie in this field; trying to learn as much as possible. I tried Jawahar's code, and like u said it did throw an exception at this line:

since ServletConfig is undefined. I modified the code and included the call to super.init(config);
but ended up with a null pointer exception saying:

Below is my sample program:

Why is this happening?
22 years ago
Thank you Rick for that answer. I can sleep better now.
22 years ago
Hi All,
I've been wondering for some time as to why the HttpServlet class in the javax.servlet.http package is declared abstract.
As far as I can see, it does not contain any abstract methods and has implemented the abstract "service" method in the GenericServlet class.
Can someone enlighten me on this? Thank you in advance.
22 years ago
Love your determination Guy! Congrats and keep at it.
23 years ago
Hi Sonir,
All the best for the coming exams. I did a lot of test programs, just to see how certain codes would be compiled and executed. This really helped me in understanding the concepts.
For the purpose of the exam, I bought 2 books and they're really good. They are:
The Complete Java 2 Certification Study Guide (Simon Roberts, Philip Heller and Michael Ernest)
Java 2 Exam Cram (Bill Brodgen)
Read and understand all 13 chapter in the Roberts book and all the chapters in the Brodgen book. What especially helped me were the mock exams in the CD included in the Roberts book. Do all the mock exams in the CD. I think there are 4 or 5 of them. The questions presented is very similiar in nature to the real exam.
There are also a lot of questions in the Brodgen book. Attempt them all and read the explanations. They're very good.
Both books can be bought through amazon.com or hopefully, from a local bookstore.
If you think you don't have the time to read both books, then I recommend that you buy one of them. Browse both books and choose the one you feel will help you most.
Also, visit these sites:
www.jchq.net
www.javaprepare.com
www.javaranch.com (I'm sure u know this already)
www.ibiblio.org/javafaq
The last site actually provides Java lecture notes taught in an American university. I found them very helpful in the initial stages of learning Java.
Phew! That's was a lot! All the best again and be cool and calm when taking the exam. It definitely helps.
Gaia.
[ January 08, 2002: Message edited by: Gaia Nathan ]
23 years ago
Hi all,
I want to thank each and everyone of you who have helped me so much in my preparation for the SCJP exam. For the record, I scored 86% in the exam.
You guys are the best! Gaia.
23 years ago
Hi all,
I want to thank each and everyone of you who have helped me so much in my preparation for the SCJP exam. For the record, I scored 86% in the exam.
You guys are the best! Gaia.
23 years ago
Hi all,
I know that the abstract and final modifiers cannot be used together, but are there any other restrictions on the other modifiers, such as native, transient and so on?
Also, can static and transient modifiers be used together?
Thanks in advance for the help.
Gaia.
23 years ago
Thanks Colin, I get it now.
Gaia
23 years ago
Thanks Shiva, Marilyn for your replies.
Quoting Shiva:
I think for Anonymous inner class we can able to call any outer class function, but member variable needs to be final.
Yeah, anonymous classes can access both the member variables and methods of the enclosing class but can only access final local variables of the method in which it is declared in.
Phew!
Actually the part I was confused is this:
MyInner aMyInner = .....
Shouldn't it be MyOuter.MyInner instead of just MyInner?
Once again, thanks in advance.
23 years ago
Hi All,
To the best of my knowledge, a static inner class does not require an instance of the outer class to exist. Also, the static inner class must be referenced by the name OuterClass.InnerClass
Why then does this code compile?
public class MyOuter {
public static class MyInner {
}

public static void main(String[] args) {
MyInner aMyInner = new MyOuter.MyInner();
}
}
Shouldn't the declaration:
MyInner aMyInner = new MyOuter.MyInner();
generate a compile-time error?
Another question: Can an anonymous class access the member variables and methods of the outer class?
I'd appreciate any replies. Thanks.
Gaia.
23 years ago
Hi Christopher,
Doesn't "Enough" get printed out as well? Can you show me the flow of control in the code?
Thanks.
Gaia.
23 years ago
Hi all,
Thank you for all your replies.
Found this in Chapter Four (of the same book):
Quote:
... Java relaxes its assignment conversion rule when a literal int value is assigned to a narrower primitive type (byte, short, or char) provided the literal value falls within the legal range of the primitive type.
End quote.
So, I guess this is why
byte x = +2;
is allowed.
+2, which is an int literal value, has a magnitude that falls within the legal range of the byte primitive data type.
Thanks again.
Gaia.
23 years ago
If I'm not mistaken Dale, all strings created using the "new" keyword are stored in the heap, just like all other objects.
These strings will be subject to garbage collection should no variable reference them.
23 years ago