Question
A Class with Member Variables (Instance Variables) and Methods In this assignment you will implement a Java class definition containing member variables (also known as
A Class with Member Variables (Instance Variables) and Methods
In this assignment you will implement a Java class definition containing member variables (also known as instance variables, or fields) and methods. You are not implementing a Java program, and your class definition should not have a public static void main() method.
Your class needs to have eight member variables, and it needs to have one member variable for each primitive type in the Java language. The eight primitive types in Java are: int, double, boolean, char, byte, short, long, and float. Your class should declare one member variable of each of these eight types. You may declare the variables in any order you like, and name the variables whatever you like, but remember that your class will not compile if your variable name is not a valid Java identifier, and it will not compile if a variable is declared to have the same name as another variable. See BPwJfD Listing 17-2 (pg 335) for an example of how to declare classes with instance variables. You do not need to use modifiers like public, private or static on any of these member variables.
Your class also needs to have two methods:
One method must be named foo. Your foo method must have a return value type of void, and must have one parameter/argument of type double.
The second method must be named bar. Your bar method must have a return value type of char, and must take no parameters/arguments.
You are not required to put any functionality inside either of these methods, except for a return statement, which is required for bar because it returns a value of type char. You may implement bar to return any char value that you like. You do not need to use modifiers like public, private or static on these methods.
Your class should be called MembersOnly, and it should be in a file called MembersOnly.java. We suggest that you make sure that your MembersOnly class can compile by creating it in Eclipse using File->New->Class, and making sure that there are no red xs in the code panel when you save it. You wont be able to run this class as a program, because it wont have a public static void main().
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