package day3.inheritance; //base class or parent class or super class public class Box { public void calculateArea(int length, int width) { System.out.println("Area is: " + (length*width)); } } ============================================ package day3.inheritance; //Inheritance: when a class acquires properties of another class //subclass public class NewBox extends Box { public void calculateVolume(int length, int width, int height) { System.out.println("Volume= " + (length*width*height)); } public void calulateArea(int length, int width) { System.out.println("Sub area = " + (length / width)); } } ================================================================== package day3.inheritance; public class TestBox { public static void main(String[] args) { Box FedEx = new Box(); FedEx.calculateArea(3, 4); NewBox ups = new NewBox(); ups.calculateVolume(4, 5, 6); ups.calculateArea(4, 2); } }
public void calulateArea(int length, int width) {
calculateArea
System.out.println("Sub area = " + (length / width));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)