Interface Program in Java | ISC 2020
Interface Program in Java | ISC 2020
An interface Data is defined with a data member and a method volume() which returns the volume of the implementing shape. A super class Base has been defined to contain the radius of a geometrical shape. Define a sub class CalVol which uses the properties of the interface Data and the class Base and calculates the volume of a cylinder.
The details of the members of the interface and both the classes are given below:
Interface name: Data
Data member:
double pi: initialize pi = 3.142
Member functions/methods:
double volume()
Class name: Base
Data member/instance variable:
rad: to store the radius in decimal
Member functions/methods:
Base(...): parameterized constructor to initialize the data member.
void show(): displays the radius with an appropriate message.
Class name: CalVol
Data member/instance variable:
CalVol(...): parameterized constructor to initialize the data members of both the classes.
double volume(): calculates the volume of a cylinder by using the formula (pi × radius × radius × height)
void show(): displays the data members of both the classes and the volume of the cylinder with appropriate message.
Assume that the interface Data and the super class Base has been defined. Using the concept of inheritance, specify the class CalVol giving the details of the constructor, double volume() and void show.
The interface, super class, main function and algorithm need not be written.
#interface #java #isc #computerscience #inheritance
Other Videos By Robin Sir
2023-06-26 | Prime Factorization in Java |
2023-06-25 | Happy Number in Java |
2023-06-24 | Matrix Transpose in Java |
2023-06-23 | Kaprekar Number in Java |
2023-06-22 | Palindrome Words in Java |
2023-06-21 | Fibonacci Term using Recursion |
2023-06-20 | GCD in Java using Recursion |
2023-06-19 | Factorial in Java using Recursion |
2023-06-18 | Binary Search Tree in Java |
2023-06-17 | Deque Program in Java |
2023-06-16 | Interface Program in Java | ISC 2020 |
2023-06-15 | Circular Queue in Java |
2023-06-14 | Lead Number in Java |
2023-06-13 | Duck Number in Java |
2023-06-13 | Pig Latin Program in Java |
2023-06-11 | Queue on Array in Java |
2023-06-07 | Linked List in Java |
2023-06-06 | Stack on Array in Java |
2023-06-06 | Abundant Number in Java |
2023-06-04 | StringTokenizer in Java |
2023-06-03 | Input & Output to Binary File in Java |