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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started