Page 355 - CA_Blue( J )_Class10
P. 355

class base





                                       class derive1           class derive2           class derive3


                 14.4.5 Hybrid Inheritance
                 When more than one type of inheritance is coded together, then it is termed as hybrid inheritance.

                                                                class super1




                                     class super2                class sub1                class super3



                                                                 class sub


                 In the above example, multiple and multilevel inheritance are combined together.

                 14.4.6 Why Inheritance is Required?
                 Inheritance is mainly required to reuse the properties (Data Members and Methods) of one class within another class.
                 This helps to reduce the program code and makes easier to debug any error in the program.



                                Let’s Revisit


                       ®  Encapsulation is a process that depicts the idea of bundling data and functions together.
                       ®  An access specifier is a property that controls the accessibility of data members and member methods within the
                       class or outside the class.
                       ®  Class variables are also known as static data members.
                       ®  An argument is a value that is passed to a method when it is called. It is also called actual parameter.
                       ®  A block basically means the sequence of statements within curly brackets (also known as braces).
                       ®  Inheritance in Java is the method which allows one class to inherit the properties (data members and member
                       methods) of another class.



                                                              MIND DRILL






                         Solved Questions



                    A.  Tick ( ) the correct answer.

                        1.  Methods and variables are enclosed within a unit called ………………….
                          a.  Method                                      b.  Block
                          c.  Class                                       d.  Package



                                                                                                                       353
                                                                                           Encapsulation and Inheritance   353
   350   351   352   353   354   355   356   357   358   359   360