wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ArithmeticException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ArithmeticException" Watch "ArithmeticException" New topic
Author

ArithmeticException

dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Please select arithmetic operations which can result in ArithmeticException

Multiplication: * -answer
Division: /
Modulo: %
Addition: +
Subtraction:-

I think the answer is Division & Modulo. Can any one please help me?


SCJP-1.5<br />SCWCD-1.4
Lucky J Verma
Ranch Hand

Joined: Apr 11, 2007
Posts: 278
Yaa ,i also think asnwer is Division.
Hows is modulo?
What is source of this Question.
Vikrant Sahdev
Ranch Hand

Joined: May 31, 2007
Posts: 58
Only Division & Modulo returns Arithmetic Exception and that too for int/ long.


Coming soon... www.javatales.com
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
int something = 3; // or 0...
System.out.println(17 % something);
What happens when you calculate 17 modulo something?
First 17 is divided by something, and then the remainder is returned.
When you calc. x % 0...

Bu.
[ September 07, 2007: Message edited by: Burkhard Hassel ]

all events occur in real time
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Hi Hassel,
So I was right. Division & modulo are the answers. Or Was I wrong?
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
No.
Onkar Joshi
Ranch Hand

Joined: Mar 01, 2007
Posts: 116
Originally posted by dolly shah:
Hi Hassel,
So I was right. Division & modulo are the answers. Or Was I wrong?


You are correct.

Read section 15.6 here for details : http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html


SCJP 5 - 95% | SCWCD 1.4 - 88% | SCBCD 5 - 93%
Onkar Joshi's blog | LinkedIn profile
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Hi Hassel,
No means I was wrong or right?
Vikrant Sahdev
Ranch Hand

Joined: May 31, 2007
Posts: 58
Yes, you are correct
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
question was: Or Was I wrong?
answer was: No.


Means you were not wrong.
Bu.
Mack Stevens
Greenhorn

Joined: Aug 31, 2007
Posts: 17
Hi............................
Try this interesting code,it will add to your knowledge.
code:
class FloatExample
{
public static void main(String ar[])
{
System.out.println(2.0/0);
}
}
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
or System.out.println(-3D/0);
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ArithmeticException