Vinod Kumar Kommineni

Ranch Hand
+ Follow
since Jun 12, 2008
Vinod Kumar likes ...
Firefox Browser
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vinod Kumar Kommineni

ya , its true GUI questions are not there for Test
Hi deepika Actually Head First is not enough for passing SCJP you need to have K&B Study Guide
getting certified as a Programmer is a pre requisite for getting certified as a Developer check this page for Certification Details
Hi Leonard

Throwable can be either checked or uncheked exception

and also same is the case with Exception it will be a checked exception unless it belongs to RuntimeException branch ,

so declaring it here like this

is basically violating the rule that : new or wider checked Exception that are not thrown by super class version of a method should not be thrown by its overriding versions

because when you are calling the super class version it might throw a Throwable which is super class to the class Exception (Since it's a super class version , it can throw a wider Exception)

so modifying the code to handle it will solve the issue:

or else if you modify the super class method implementation and make sure it throws Excepetion

it should work i guess.

for Throwable there is no problem because when you are saying

it should handle it or the method calling will handle it but its a Throwable in both cases which is the super class of all errors and exceptions in the Java language.
so its not showing any compilation error i guess.

I hope this explanation is correct.

Some one correct me if i am wrong
Hi Priyanka,

welcome to java ranch

which book are you following for your preparation?
SCJP 5 book would do can refer on net for the extra topics added .
some times it happens.. silly mistakes
Hi, sumeet
please modify your code as follows and try

you are trying to put the element in to an int with out checking weather its an int or not.
I think you will get it now

for non static synchronised method:
each object has its own lock and non-static synchronised code cannot be entered by a thread if another thread already has taken that particular object's lock.
basically Non-static synchronized methods synchronize on the instance (this) of the class.

for static synchronised metods:
Static methods use the class as the object for locking

you are getting following lines of error
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(
at java.util.Scanner.nextInt(
at java.util.Scanner.nextInt(
at ScanTest.main(

because you are trying to parse a String into an int

and regarding the concept of exhausting basically you are reaching the end of the scanner ,that is the last element in the while loop itself .
so you don't have any more elements to scan
sumeet ,
i think you are trying to put a string into int, change the code

and try it ,if you get the same error please post