Page 107 - ComputerScience_Class_11
P. 107

B.  Fill in the blanks.
                    1.  A ………………… is also known as machine code and is directly understood by the computer.
                    2.  During execution of a program, the occurrence of any error stops the execution. This situation is known as an ………………….
                    3.  ………………… is the procedure of combining data and functions together.
                    4.  A class from which another class inherits its features is called a ………………….
                    5.  Java uses both compiler as well as ………………… .

                   Answers
                     1.  machine language           2.  exception                 3.  Encapsulation
                     4.  superclass                 5.  interpreter


                 C.  Answer the following questions:
                    1.  Name the types of Java programs.
                   Ans.  There are two types of Java programs, which are as follows:
                        •  Java Standalone Applications
                        •  Java Applets
                    2.  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.
                    3.  Describe data abstraction with suitable examples.
                   Ans.  Data abstraction is the property by which the essential features of a class are represented without knowing the background
                       details that how they are actually executing, i.e., non-essential units are hidden from the user.
                        For example, while travelling in a car as a passenger, you think only of reaching the destination. But you never think of how the
                       driver is driving the car by pressing the clutch, brake and accelerator as and when required.
                    4.  Write any four characteristics of procedure-oriented programming languages.
                   Ans.  Some of the characteristics of procedure-oriented programming language are as follows:
                        •  Emphasis is given on procedure rather than data.
                        •  Functions are the sub-programs that are the parts of the larger programs.
                        •  Most of the functions share global data.
                        •  Functions transfer data from one function to another.
                    5.  Explain object-oriented programming languages with suitable examples.
                   Ans.  Object-oriented programming languages are programming languages in which programs are organised around objects rather
                       than functions. In OOP, data cannot flow freely from one function to another. It can be accessed only through the methods of the
                       object. Some of the examples of object-oriented programming languages are Java, C++, C#, Python, etc.
                    6.  What were the five main objectives kept in mind while developing the Java language?
                   Ans.  The five main objectives that were kept in mind while developing the Java language are as follows:
                       •  Coding should be simple and object-oriented.
                       •  It must be dynamic and secure.
                       •  It must be architecture-neutral and handy.
                       •  The program should execute with high performance.
                       •  It should be platform-independent and threaded.
                    7.  What is a compile-time error? Explain it with a suitable example.
                   Ans.  While coding, a grammatical error leads to a syntax error. The compiler stops the execution of the program as soon as it encounters
                       a syntax error. So, the code needs to be corrected before execution.
                        Let us consider an example to find the area of a rectangle.
                       class syntax_error

                       {
                           void calculate(int l, b)
                           {
                               int ar = l * b;



                                                                  Introduction to Object-Oriented Programming Using Java  105
   102   103   104   105   106   107   108   109   110   111   112