This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Syamsul Hussin

Ranch Hand
+ Follow
since Feb 09, 2003
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 Syamsul Hussin

anuragk,

The way i usually think about compile time and runtime error is to figure out the information available to the compiler during compile time.



1. what about signature of method (when wrong, will give compile time or runtime error)



Lets look at an example



The compiler has all the information to conclude that there is not enough information to disambiguate the two methods. This error will be captured by the compiler.



trying to override a final method?



Same case. If a method has been tag with a final modifier, the compiler will immediately detect the error of trying to override it.


3.and in some cases when we implement rumtime polymorphism, it will also give compile time error



With polymorphism, sometime the type of an object could only be determined at run time.



Lets say int A is the user's input. There is no way the compiler could tell the type of o in advance. If A is not 1 then it will be a runtime error.
[ October 26, 2006: Message edited by: Syamsul Hussin ]
13 years ago
Yes, syntax error is a type of compile time error, but the compiler does more than just syntax checking, it also does some static checking to catch obvious errors.

eg.



although syntatically correct, the compiler will flag a compile time error because a wasnt assigned a value before being used (obvious bug).
13 years ago
The compiler will try its best to detect errors during compilation, eg



since Integer can never be a double, then the compiler detects this obvious mistake and flags a compilation error.

A runtime errors are errors that is impossible for the compiler to detect at compile time, eg.



may or may not throw a runtime cast exception depending on the type of o (if its not a String, then the program would halt and the vm will flag a class cast exception). There is no way that the compiler could anticipate the type of o during compilation time. Hope this helps.
13 years ago
Hi,

you could use get method to obtain the reference again

13 years ago
Overflow?



gives..



hope this helps.
13 years ago
i think a good way to disambiguate between wildcards ('?') and just generic type ('E') is to present a situation where the use of wildcards is the only choice. I've tried to look around but can't find that situation. am still confused.

tia.
13 years ago
But it seems that you dont have to bound the generic type when calling a static method, so the syntax to call both methods should be the same.
tia.
13 years ago
i'm confused about why we need a different syntax for ? (wildcards). if i have a method



that iterates through the list and prints out every object in the ArrayList then this code



should be able to achieve the same effect.

tia.
13 years ago
Hello, i've got this major problem with cookies,

I've got a form, and when the user clicks the submit button, a new cookie will be constructed (based on info entered by the user), and

is called.

I've got a protion of the jsp that will get all cookies via

and prints out all cookies to the webpage.

The problem is, I have to refresh the page after clicking submit in order for the webpage to print the cookie (it doesnt display after the click).

I've tried these combinations of getting the cookies first, then adding them and adding them and then getting them back.

On the other hand, cookie.setValue() seems to work instantaniously (displays changes after a click).

I'm very confused as why this is happening. All help welcomed, thanks in advance.
15 years ago
JSP
hi i just passed scjp exam with 75%.
java experience:1 year(1st year college)
preperation:2 months
Thread questions were very difficult! Thanks to all ranchers the scjp discussion board really helped.
[ September 22, 2003: Message edited by: Syamsul Hussin ]
16 years ago
can a local inner class defined within a static method access the top class non-static member?
eg.

can codes in the area labelled here access int A? thanks.
pls help me with this question

Answer is C.
i thought the answer is B.
thanks
can a method throws runtimeexception?
e.g
public void aMethod throws RuntimeException(){}
?
thanks
can we have abstract and static methods? why not?
can we override static methods?
thanks.