The Java feature in Q1 which create a new version of predefined method getPerimeter() is called     Polymorphism     Override     Overload     Inheritance

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 6E
icon
Related questions
Question

1: create a class Pentagon, which implements the RegularPolygon interface. It should have a double field called length, as well as a constructor that initializes this length field to a given value.

2: 

In the main() method of Pentagon class, add the following code:

 

RegularPolygon sq = new Square(10);

RegularPolygon penta = new Pentagon(20);

 

Write code to get the perimeter for sq and penta. 

3: 

In the main() method defined in Q2, add this line of code: 

sq.getArea();

Will this code pass through compiler? What is the reason?

 

  1. The Java feature in Q1 which create a new version of predefined method getPerimeter() is called

       

    Polymorphism

       

    Override

       

    Overload

       

    Inheritance

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT