Page 104 - computer science (868) class 11
P. 104

6.  Why class is known as an object factory?
                Ans.  Factories are places which produce products of the same kind. A class acts as a factory as by using it, similar types of objects are
                    created with different characteristics and common behaviours. We can also say that a class is a blueprint of objects. Hence, a class
                    is called the object factory.
                  7.  Why an object is known as an instance of a class?
                Ans.  As soon as an object is created in Java, it acquires memory in RAM but this does not happen while defining a class. Thus, objects
                    are the physical existence of the class.
                    We know that data types such as int, long, float, etc. are predefined classes in Java, similarly, user-defined classes create objects
                    that contain all the properties and methods of those classes, and also acquire memory.
                     Thus, we can say an object is an instance of a class.
                  8.  What do you mean by exception handling?
                Ans.  When an exception occurs, the program stops immediately with a system-generated message. To provide a user-friendly message,
                    we need to handle the raised exceptions. Using it, we can ensure that the flow of the program doesn’t break when an exception
                    occurs. So, exception handling is a mechanism to handle errors occurred during the execution of the program so that the normal
                    flow of the code can be maintained.

                   Unsolved Questions



              A.  Tick ( ) the correct option:
                  1.  Which of the following is a function or method that has the same name as the class?
                    a.  Variable                                    b.  Constructor
                    c.  Method                                      d.  Object
                  2.  If there is any error in an arithmetic operation, then …………………. error is thrown.
                    a.  IOExceptions                                b.  NullPointerException
                    c.  ArithmeticException                         d.  None of these
                  3.  The interpreter converts high-level program statements into …………………. .
                    a.  machine language                             b.  assembly language
                    c.  Both a and b                                 d.  None of these
                  4.  When the …………………. statement executes, the nearest catch statement is checked for checking what type of exception has
                    raised.
                    a.  try                                         b.  catch
                    c.  throw                                       d.  finally
              B.  Fill in the blanks:
                  1.  The …………………. are the physical existence of the class.
                  2.  Except …………………, all exceptions are known as the checked exceptions as they are checked by the compiler.
                  3.  [class name] [space] [object name] = new [space][constructor]; this is the syntax to create an ………………… .
                  4.  ………………… is a mechanism to handle errors occurred during the execution of the program.

              C.  Answer the following questions:
                  1.  Write the features of Java Virtual Machine.
                  2.  What is bytecode?
                  3.  Mention the steps to use a Scanner class.
                  4.  What do you mean by the “throws” keyword in Java?
              D.   Assertion and Reasoning Based Question.
                   Assertion:  Exception handling is a mechanism to handle errors that occur during the execution of the program so that the normal
                          flow of the code can be maintained.
                   Reason: During the execution of a program, an error may occur which may stop the execution of the program.
                  (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.
                  (c)    Assertion is true and Reason is false.
                  (d)  Assertion is false and Reason is true.



                102102  Touchpad Computer Science-XI
   99   100   101   102   103   104   105   106   107   108   109