Page 317 - CA_Blue( J )_Class10
P. 317

39                  tw="";
                  40              }

                  41
                  42          }

                  43      }
                  44

                  45      void display()
                  46      {

                  47          System.out.println("Number of word " + word +" present "+ count);
                  48      }

                  49
                  50      public static void main()
                  51      {

                  52          sentence ob = new sentence();

                  53          ob.input();
                  54          ob.check();
                  55          ob.display();

                  56      }
                  57  }

                 You will get the following output:












                                Let’s Revisit



                       ®  A constructor is a type of special member method with same name as of class.
                       ®  A default constructor is used to initialize the instance variables automatically with default values.
                       ®  A parameterised constructor is a type of constructor with parameters and statements inside its body.
                       ®  A non-parameterised constrictor is a type of constructor without parameters.
                       ®  The copy constructor is a special type of constructor that is used to create an object by initialising it with previously
                       created object of the same class.
                       ®  Constructor overloading is a technique of using a number of constructors in a class with different number of
                       parameters or different types of parameters.






                                                                                                                       315
                                                                                                         Constructors  315
   312   313   314   315   316   317   318   319   320   321   322