Computer scienceProgramming languagesKotlinObject-oriented programmingClass hierarchy

Overriding properties

Square class and properties

Report a typo

Create an abstract class Shape with an abstract property area. Add a subclass Square and override the area property with the length of the side of the square.

Sample Input 1:

4

Sample Output 1:

16

Sample Input 2:

5

Sample Output 2:

25
Write a program in Kotlin
abstract class Shape {
// make your code here
}

class Square(val side: Double) : Shape() {
// make your code here
}
___

Create a free account to access the full topic