Question: java Define a class and name it as Lion. Add the following inside the class. 1. Define instance variables species, color, weight 2. Add a

 java Define a class and name it as "Lion". Add the

java

Define a class and name it as "Lion". Add the following inside the class. 1. Define instance variables species, color, weight 2. Add a parameterized constructor which will take 3 parameters. Inside the constructor initializes the attributes with the parameters passed to the constructor. 3. Add the following methods. a. public void hunt(String prey) - Inside the method, print "species like to hunt prey." where species is the value of the species attribute and prey is the value of the parameter passed to the method. b. public double getWeight() - the method should return the weight attribute. c. public void display() - inside the method, print the value of all three attributes. Question 2: [8] Define a class and name it as "TestLion". Define the main method inside the class. Inside the main, do the following. 1. Create an object of Lion class name="Royal Bengal Tiger", color=" Golden" and weight =200. Store the reference to a variable name myLion. 2. Call the hunt(...) method using the myLion variable and pass "deer" as the parameter of the method. 3. Call the display(...) method using the myLion. - What is the output of this method

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!