Page 130 - ComputerScience_Class_11
P. 130

1.  Assertion (A): 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 (R): During the execution of a program, an error may occur which may stop the execution of the program.
                Ans.  a. Both A and R are true and R is the correct explanation of A.
                  2.  Assertion (A): A class is a user-defined data type that acts as a blueprint for creating objects of the same type.
                     Reason (R): A class is created once in a program.
                Ans.  c. A is true but R is false.
                  3.  Assertion (A): A Java Virtual Machine (JVM) converts Java bytecode to machine-dependent code so that it could be executed.
                     Reason (R): It enables a computer to run Java programs as well as programs written in other programming languages that are also
                    compiled to Java bytecode.
                Ans.  b. Both A and R are true but R is not the correct explanation of A.

              F.  Case study-based questions.
                     In a school management system, a Student class is used to manage details of students. Each student has specific characteristics
                    and behaviours. The system needs to represent these students as objects.
                     •  The characteristics of a student are:
                      o  Name
                       o  Roll number
                       o  Class
                      o  Gender
                     •  The behaviours of a student are:
                       o  Whether the student is good in studies
                       o  Whether the student participates in extracurricular activities
                     The Student class has data members for the characteristics and methods for the behaviours. The system creates student objects
                    and performs operations like checking the student’s academic performance and participation in extracurricular activities.
                     Based on the given case, answer the following questions:
                     1.  What is the role of a class in this case study?
                       a.   A class defines a blueprint for creating objects   b.  A class holds the student data
                       c.   A class stores the student’s results    d.  A class only performs calculations
                     2.  How does the Student class represent behaviours?
                       a.   Through data members                    b.  Through methods
                       c.   By assigning values                     d.  Through events

                     3.  What is the relationship between the Student class and the objects created in the program?
                       a.   A class is an instance of an object     b.  An object is an instance of a class
                       c.   A class contains the data only          d.  Objects do not exist in this system

                Answers
                  1.  a     2.  b     3.  b



              G.  Identify the error in the given codes and rewrite the correct code:
                  1.  import java.util.Scanner;
                    class EvenOdd {
                        public static void main(String[] args) {
                            Scanner sc = new Scanner(System.in);
                            System.out.print("Enter a number: ");
                            int num = sc.nextInt();




                  128  Touchpad Computer Science (Ver. 3.0)-XI
   125   126   127   128   129   130   131   132   133   134   135