Page 151 - CITS - CSA - TP (Volume 2) - Hindi
P. 151

कं  ूटर सॉ वेयर ए ीके शन - CITS




               }
           }
           // Subclass

           class Circle extends Shape {
               double radius;

               // Constructor
               Circle(String color, double radius) {
                   super(color); // Call superclass constructor

                   this.radius = radius;
               }
               void displayRadius() {

                   System.out.println(“Radius: “ + radius);
               }
           }



           // Main class
           public class ShapeDemo {

               public static void main(String[] args) {
                   // Create an instance of the Circle class
                   Circle circle = new Circle(“Red”, 5.0);



                   // Call the displayColor and displayRadius methods

                   circle.displayColor();
                   circle.displayRadius();
               }

           }


           आउटपुट:
























                                                           137

                                  CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 100
   146   147   148   149   150   151   152   153   154   155   156