Answer to Question #95983 in Java | JSP | JSF for Yogaletchmi A/P Yugarajan

Question #95983
Write a program to define a class Shape with data members row and column. The superclass has a constructor that used to set row and column and method rectangle() with access specifier ‘protected’ which used to display the shape of rectangle.
1
Expert's answer
2019-10-07T08:38:11-0400
class Shape {
    private int row;
    private int column;

    public Shape(int row, int column){
        this.row = row;
        this.column = column;
    }

    protected void rectangle(){
        if(this.row == this.column)
            System.out.println("This shape is a square.");
        else
            System.out.println("This shape is a rectangle.");
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS