Page 463 - Cs_withBlue_J_C11_Flipbook
P. 463

30                  { wo2=wo1.substring(ps)+wo1.substring(0,ps)+"AY"; }
                  31              ns=ns+wo2+" ";

                  32           }
                  33           System.out.println(ns);

                  34          }
                  35      }

                 The output of the preceding program is as follows:
                 Enter the sentence
                 The clear blue sky and vast ocean!
                 ETHAY EARCLAY UEBLAY SKY ANDYAY ASTVAY OCEANYAY



                                Let’s Revisit



                       ♦ Package in Java is a container for groups of related classes, sub-classes, sub-packages, and interfaces. It helps organiseJava
                      classes into a separate namespace which makes it easy to locate.
                       ♦ A package has the following advantages: (i) reusability (ii) better organisation (iii) no naming collision (iv) access protection.

                       ♦ Packages can be classified into two types: (i) Built-in packages (ii) User-defined packages.
                       ♦ Built-in packages are the already defined package in Java software like java.io.*, java. lang.*  etc.
                       ♦ User-defined packages in Java are the packages that are created by the programmer.
                       ♦ Several built in packages of Java API are java.lang , java.util, java.net, java.applet, java.io, java.awt, java.sql.
                       ♦ The import keyword is used to make the classes and interface of another package accessible to the current package.
                       ♦ Every class belongs to a package. If we omit the package statement, the class names are put into the default package.
                       ♦ A class can have only one package statement but it can have multiple import package statements.






                                                                 MIND DRILL







                      Solved Questions



                 A.  Tick ( ) the correct option:
                    1.  Which of the following in Java is a container for groups of related classes, sub-classes, sub-packages, and interfaces?
                       a.  Abstraction                                 b.  Encapsulation
                       c.  Binding                                     d.  Package
                    2.  Which of the following is an advantage of Java package?
                       a.  Reusability                                 b.  Naming collision
                       c.  Global access                               d.  Inheritance




                                                                                                                       461
                                                                                                            Packages   461
   458   459   460   461   462   463   464   465   466   467   468