Page 141 - Computer science 868 Class 12
P. 141

7.  Derived classes are also known as ………………… .
                    8.  ………………… contains all mathematical methods such as sqrt(), cbrt(), pow(), max(), etc.

                   Answers
                     1.  objects      2.  Documentation Comments     3.  java applet    4.  java.lang    5.   independent
                     6.  Comments        7.  child class          8.  java.math


                 C.  Answer the following questions:
                    1.  Define inheritance.
                   Ans.  Inheritance in Java is the method that allows one class to inherit the properties (data members and member methods) of another
                       class.
                    2.  What is the difference between a superclass and a subclass?
                   Ans.  The difference is as follows:
                        Superclass: It is the class from where features are inherited to another class. It is also known as base class or parent class.
                        Subclass: It is the class that inherits the features of another class. It is also called the derived class or extended class or child
                       class.
                    3.  Define polymorphism.
                   Ans.  In object-oriented programming, polymorphism is the feature of being able to allot a dissimilar meaning so that a variable, a
                       method or an object can have more than one form.
                    4.  Who are the creators of Java?
                   Ans.  The creators of Java are:
                        a.  James Gosling
                        b.  Patrick Naughton
                        c.  Mike Sheridan
                    5.  Name the types of Java Programs.
                   Ans.  Two types of Java Programs are standalone applications and applets.
                    6.  Define interpreter.
                   Ans.  An interpreter is a program that converts the source code into machine language.
                    7.  How many types of comments are there in Java? Name them.
                   Ans.  There are three types of comments in Java. They are as follows:
                        a.  Single line Comments
                        b.  Multiline Comments
                        c.  Documentation Comments
                    8.  Define single-line comments.
                   Ans.  Some comments exist in one line only. It may be written in a fresh line or after the end of the statement.
                        The symbol is //
                    9.  Define multiline comments.
                   Ans.  When we need to explain certain lines, Multiline Comments are used. These types of comments help to write more than one line
                       so that the logic of the code can be explained in detail.
                        The symbol is /* .... */
                    10.  Define documentation comments.
                   Ans.  The documentation comments are used to write the documentation part of the program such as the question of the program,
                       name of the programmer, etc.
                 D.  Assertion and Reasoning Based Question.
                    Assertion: Inheritance in Java is the method to create a hierarchy between classes by inheriting attributes from other classes.
                    Reason:  Inheritance in Java supports the concept of reusability where some portion of the program code can be used multiple times
                           so that the program code can be reduced.
                    (a)  Both Assertion and Reason are true, and Reason is the correct explanation for Assertion.
                    (b)  Both Assertion and Reason are true, but Reason is not the correct explanation for Assertion.


                                                                                                                       139
                                                                                                   Programming in Java  139
   136   137   138   139   140   141   142   143   144   145   146