Question: Problem #3 LongInteger Class Implement a class named LongInteger. The class contains: A private data field of type long A constructor that takes parameter of

Problem #3

LongInteger Class

Implement a class named LongInteger. The class contains:

A private data field of type long

A constructor that takes parameter of type long and creates LongInteger object for the specified long value.

toLong() method that returns the value of the field.

The instance methods isEven(), isOdd(), and isPrime() that return true if the value in the object is even, odd, or prime respectively.

The static methods isEven(long), isOdd(long), and isPrime(long) that return true if the specified value is even, odd, or prime respectively.

The instance method equals(long) and instance method equals(LongInteger) that return true if the value in this object is equal to the specified value.

A static method parseLong(String) that converts a string into an long value, positive or negative. Method throws IllegalArgumentException when

A string contains non-digit characters (other than '-' as the very first character of the sting).

A string has only '-' and no digits.

A string represents a number that is too large to be stored as long and produces overflow

A string represents a number that is too small to be stored as long and produces underflow

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!