Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

John is a final year student of the SCOPE department at VIT - AP University. The placement season is on and he will be sitting

John is a final year student of the SCOPE department at VIT-AP University. The placement
season is on and he will be sitting for the campus interviews. He and his friend Bob were
brushing up their Java concepts one day before the placements. Bob asked John to write a Java
program that utilizes the concept of an interface. Alice created an interface named Shape with
two methods as depicted below:
public double periTriangle (double side1, double side2, double side3); with three double
arguments. The method returns the perimeter of the triangle.
public double periRectangle (double side1, double side2); with two double arguments.
The method returns the perimeter of the rectangle.
John attended Object Oriented Programming lectures at VIT-AP and he knows that he cannot
instantiate the Shape interface and so cannot access the member functions of the Shape
interface. So, he created a class named Perimeter and is public that implements an interface
Shape. The Perimeter class provide the implementation (calculates the perimeter) of both the
methods of an interface and the perimeter is returned from the respective methods. In
Perimeter class, declare 4 instance variables namely double side1, double side2, double side3,
and double perimeter and take the values of the variables double side1, double side2, double
side 3 from the user. Create an object of the Perimeter class and access the instance methods
periTriangle and periRectangle. (NOTE: For calculating the perimeter of a triangle use
the formula, perimeter = side 1+ side 2+ side 3 and for calculating the perimeter of a
rectangle use the formula perimeter side 1+ side2
image text in transcribed

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

More Books

Students also viewed these Databases questions

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago