Inheritance is a mechanismin which one class acquires the property of an other class. For example, a child inherits the traits of his/her parents. (a) Understand the program code below in Figure 1 and...


Inheritance is a mechanismin which one class acquires the property of an other class.<br>For example, a child inherits the traits of his/her parents.<br>(a)<br>Understand the program code below in Figure 1 and answer the<br>following questions.<br>class shape {<br>protected int length, width;<br>void set (int a, int b) {<br>length<br>width = b; }<br>void show ()<br>= a;<br>{<br>System.out.println (length+

Extracted text: Inheritance is a mechanismin which one class acquires the property of an other class. For example, a child inherits the traits of his/her parents. (a) Understand the program code below in Figure 1 and answer the following questions. class shape { protected int length, width; void set (int a, int b) { length width = b; } void show () = a; { System.out.println (length+" "+width); }} class rectangle extends shape { int area; void setArea () { area= length*width;} void show () { System.out.println (area); }} class AreaRec{ public static void main (String [] args) { rectangle r= new rectangle () ; r. Set (4,10); r. Show () ; r. SetArea () ; r. Show () ; }} Figure 1: Rectangle area i. Identify the output of the program above. Please show the tracing table.

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here