Method overriding basics
Java
Easy
6 views
Problem Description
Task: create Shape base and Rectangle child overriding area().
Output Format
Return value
Constraints
Use polymorphism.
Official Solution
static abstract class Shape{abstract int area();}static class Rectangle extends Shape{final int w,h;Rectangle(int w,int h){this.w=w;this.h=h;}int area(){return w*h;}}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!