Page 265 - CA_Blue( J )_Class10
P. 265

9           System.out.println("Enter Length and Breadth");
                  10           length=sc.nextInt();

                  11           breadth=sc.nextInt();
                  12       }

                  13
                  14       public void area_rec()

                  15       {
                  16           int area= length * breadth;

                  17           System.out.println("Area of the Rectangle : "+area);
                  18       }

                  19
                  20       public void perimeter_rec()

                  21       {
                  22           int peri= 2 * (length + breadth);

                  23           System.out.println("Perimeter of the Rectangle : "+peri);
                  24       }

                  25
                  26       public static void main ()

                  27       {
                  28           rectangle ob= new rectangle ();

                  29           ob.input();
                  30           ob.area_rec();

                  31           ob.perimeter_rec();
                  32       }
                  33   }



                     11.5 DIFFERENT COMPONENTS OF A CLASS
                 The different components of a class are as follows:
                 •  Access Specifiers
                 •  Data Members
                    i.  Instance variables
                    ii.  Class variables
                    iii.  Local variables
                 •  Member methods
                 •  Static Member Methods
                 •  Constructors

                 Let us study in detail.


                                                                                                                       263
                                                                                      Class as the Basis of all Computation  263
   260   261   262   263   264   265   266   267   268   269   270