Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 [ 5 marks ] : Write a Java class with a method that takes integer value as a parameter. If the remainder of

Question 1[5 marks]:
Write a Java class with a method that takes integer value as a parameter. If the remainder of the division of this number by 2 is different from zero, it throws an ArithmeticException otherwise it prints a message Even number. Write a main method to test your code.
Question 1[5 marks]:
Write two Java classes that implement differently an abstract method of an interface. This method calculates the distance between two points. The distance can be calculated as follows (x1, x2, y1, y2 are double variables):
1) Math.sqrt((y2- y1)*(y2- y1)+(x2- x1)*(x2- x1))
2) Point2D.distance(x1, y1, x2, y2)
Write a main method to test your code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

Students also viewed these Databases questions

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago