Model Test Paper 9 (Unsolved)
Maximum Marks: 100
                                                                             Time allowed: Two hours
                                  Answers        to   this
                                                     Paper       be written on the paper provided separately
                                                                             must
                                           You will not be allowed to write during the first 15 minutes.
                                        This time is to be spent in         the question paper  reading
                         The time given at the head of this Paper is the time allowed for writing the answers.
                                                This Paper is divided into two Sections.
                             Attempt all questions from Section A and any four questions from Section B.
                            The intended marks               for questions           or   parts of questions         are   given   in brackets I 1.
                                                                                     SECTION A
                                                             (Attempt all questions from                   this   Section)
     Question 1
                                                                                                                                                                   20
     Choose the    correct answers and write the correct
                                                                                option.
         )    Declaration is      not to    declare "value"                   to a variable;      it is to declare the                          of the variable.
               (a) Type                                 (b) Range                                 (c) Size                          (d) None of these
        (ii) Which of the         following       is NOT               reserved
                                                                   a
                                                                                     keyword       in Java?
              (a) abstract                              (6) extends                               (c) transient
                                                                                           (d) None of these
       (ii) Which of the following                       be
                                                 method signature of the method area with two int
                                                  can          a
              (a) public int area (int length, int breadth);
                                                                                                  arguments?
                                                                   (b) area (int, int);
              (c) area (2 int);                                    (d) int area (int);
       (iv) In Java, linefeed is given by:
              (a) lb                                    (b) 1                                      (c) t                             (d) In
        (v) What does the to String (float) method do?
              (a) It   returns random string based on the argument as seed value.
                                  a
              (b) It returns a String object based on the input whose contents are the number.
              (c) Returns   float that is the
                              a                               same as          the   input      but of double data type.
              (d) None of these
       (vi) What does the method new do?
              (a) It creates a new integer
             (b)     It creates   an  of the type following
                                        object                                            new     keyword   and returns its reference
             (c) It resets all data members to 0 or null                                           (d) It returns a null object reference
      (vii) What header files           must you        import          in order to be able to             use:
             Point   ptl=   new       Point(100,100);
             (a) Java.math.*                           (b) java.util. *
                                                                                                   (c) java.awt.Point                 (d) java.lang.math
     (viii) Which method          is used     to remove                the   leading      and   trailing whitespace?
            (a) trim()                                 (b) troll()                                 (c) cut()                          (d) toTrim()
84                                                                                   Coal'h ICSCc.
        What is the output of the following code?
(ix)      tring          str                  This         is        a    string";
        Str
        la00lean             resuit                  s t r . s t a r t sWith(This");
                                                                                                                                                 (d)    None of these
         (a)    true                                       (b) false                                  (c) can't be said
         Name a Java statement to extract the second character of the string str.
 (
         (a) System.out.println(str.charA():                                                          (b)       System.out.println(charAt(o):
                                                                                                      (d)       System.out.println(str.CharAt()).
         (c) System.out.println(str.char(1):
         Choose the odd                  one    out:
                                                                                                                                                 (d) sqrt
         (a) replace()                                      (b) startsWith()                          (c) lastlndexOf)
         Give the output of the following Java statement:
(Ni)
         "TRANSPARENT".1olLowerCase()                                                                                                             (d) This is     an
                                                                                                                                                                       erroneous
                                                                                                                                                                                   statement
                                                                                                                TRANSPARENT
          (a) Transparent                                   (b) transparent                           (c)
                                                                                                                                                                        ho
                                                                                                                                                                   metnous.
                                                                                                                             variables,           classes and
                                              are            Java rescrved words                 or   titles        given to
(1)                                                 eitne                                                                                         (d)    Identifiers
                                                                                                       (c) Punctuators
             (a) Keywords                                   (b) Operators                                                                                does.
                                                                                                                                              the method
                                                                                collection of     statements                 that define what
                     function,          the                contains a
(iv) In         a
                                                                                                       (b) Parameters list
              (a)    Return statement
              (c) Method body                                                                          (d) None of these                                                          parameters.
                                                                                                                                                                  that has   no
                                                                                                                                                constructor
                             not define                constructor          for   a   class the compiler            will     supply    a
 (A) Ifyou do                                   any                                                                                                (d)   Default
              (a) Normal                                        (b) Real                               (c) Complex                                                     character.
                                                                                                                                                             returns a
                                                                                                                 integer       as an       argument and
              Write the       prototype of             a   function check which takes                   an
 (Avi)                                                                                                 (b) Character
                                                                                                                                     check     (integer):
              (a) char check              (int);                                                                   check                   (Character);
               (c) char check(Integer);
                                                                                                       (d) Integer
                                                                     initialize it                          as      h    =
                                                                                                                              new    int[6];
              If you have           a    2 dimensional array, h, and
(xvii)                                                                                                                                                                  brackets.
              It gives an error. Why?                                                                                                         with values within square
                                                                                                                h            new   int[][],
                                                                             be initialized with
                                                                                                                    =
                                dimensional                 So       must                                   ,
               (a) It is 2
                      Not as new int[6].
                                                                       elements
                                                 values to fill in the
               b) It    does not know what                                                           use.
                                                                   initialization. You can directly
                                        variable does not need
                (c) The subscripted
                (d) None of these                                            search?
                                                  search terminate in one
               In which case would binary                                                     element is the target
 (xvii)
                                                is the target
                                                                             (b) If the first
                            middle   element
                (a) If the                                                   (d) In all cases
                                  element   is the  target
                 (c) If the last                        collector solve?
                                         the garbage
     (xix)      Which problem does                                                    Java program
                                                               between objects in a
                                        c o m m o n memory
                     It  makes   use of                                                         when not used anymore
                (a)                                                                        new   and reclaim memory
                                        variables created using
                (b)     It looks at all                                                                     (d)         None of these
                                                                         to allocate memory
                (c)     It   uses       the   heap     memory
                                                                         function do in Java?
                              below call                        to a
       (xx)     What does the
                chrt         (double                a);
                                                                                                            (b)         It returns the cube root of           a
                                                                root     of a
                                              the square
                    (a) It   returns
                                                                                                            (d)         None of these
                                              the cube of        a
                    (c) It   returns
 Question 2                                                                                                                                                                                     121
                                       the Java expression:
         i)         Gives the valuc of                                                                                               ("opi")
                                                            ("abc")             &        Optim".beginsWith
                    abracad".endsWith
                                                                                                                                                                                                85
     (1)     What is the     difference in the effect of the calling the functions                         at   (1)       and   (2)   in the below   code,
            codes
                                                                                                                                                             assuming   the
                    are    written  correctly inside the functions?
             public static                 void
                                                                                                                                                                         21
                                                     main (String[1                       args)
                                    1nt a            3,             b          7
                                        Integer       g             new Integer (a);
                                        Integer       h        =
                                                                    new
                                                                               Integer (b);
                                    Swapl (a,             b);
                                    Swap2 (g, h);
    (ii) Find the value of the Java
                                    expression:                                                                                                                         21
         (int) Math. sqrt (Math.pow (4,2) +
                                                 Math.pow (7, 2) ) ;
    (IV) What does the following code do, assuming all initializations are done
         for (int i
                                                                                correctly                                                                               21
                                =
                                         0;i<       10;   i        ++)
                                yl (i+2) %10]                  =    x[il;
     (V)    Between    a   constructor and                 method, which
                                                      a                              is    necessarily called   in    a   Java    program.                          2
    (vi)    Name the kind of constructor called in the
                                                       statement below.                                                                                                 121
            Caller a       new Caller (2,3);
   (vii) What kind of statement is left blank in the below correct function definition'?
                                                                                                                                                                        [21
            public int add(int a, int b)
            (1)
   (vii) Of the below method calls in the main) method, which method call is likely to work?                                                                            121
            public         static         void       main (String []                      args)
                                         int    a     =        3
                                         Integer           b             new       Integer (a+1);
                                         (1) Update (a) ;
                                         (2)Update (b);
    (ix) Suppose that there is an aray in code with the name ar. How can you deduce the highest valued index of the array?12]
    (x) Is the below line vaid?                                                                                                                                         121
            String        str       =     abcde'";
                                                                                    SECTIONB
                                                      (Answer any four questions from this Section)
                  The answers in the section should consist of the programs in either Blue) environment or any
                                          program environment with java as the base.
                  Each program should be written using variable description/memonic codes so that logic of the
                                                                 program is clearly depicted.
                                                          Flowcharts and algorithms are not required.
Question 3                                                                                                                                                              15
           Consider the sentence as given below:
           Blue bottle is in Blue bag lying on Blue carpet
      Wrilc    a
                   program          to
                           assign the given sentence to a                             word Bluc                                        with Red at
                                                      to string variable.
                                                            cnce
                                                                          Keplacc the
                                                                variable. Replace
      all its oceurrence. Display the new
                                           string as shown below:
      Red bottle is in Red bag          on               lying          Red   carpet
Question 4                                                                                                                                                 15
       A message is to be converted by adding 10 to the total of the ASCIl code of characters in the stalement Ev
       below.      write    a
                                program             to   print the statement into            a   coded
       For example:
                                                                                                         messagc
       If a string is YORO HAS SMILIED Uhen, the coded nessage is cYUY RKJ                                                     /ON
Question 5                                                                                                                                                 15
       Define a      c l a s s to       input   a    string and convert             it   into uppercase and print   thc pair o f vowels and   numDcr   p
       of vowels occurring in the                         string   t.
       Example
       Input:
       "BEAUTIFUL BEAUTIES"
       Output:
        Pair of vowels EA, AU, EA, AU, IE
        No. of pair of vowels: 5.
 Question 6                                                                                                                                                15
        Design a class to overload a function compare ( ) as follows
                                                                              the greater of the two integers.
        (a) void compare (int, int) - to compare two integer values and print
                                                                                                               value
                                                                               character with higher numeric
        (b) void compare (char, char) - to compare the numeric value of two
                                                                                     and print the longer of the two.
         (C) void compare (String, String) to compare the length of the two strings
                                                                        -
                                                                                                                                                            |15
 Question 7
                                                                                                 is more than any other digit in the
        A Clarit number is                 a number such that the number of zeroes in the number
                                                                                                numbers are Clarit numbers or not.
         number. Write              a    class to take as input numbers and declare whether the
         For example:
         201                                             (Not)
         2003                                            (Is)
         120300                                          (is)
         3211                                            (Not)
  Question 8                                                                                                                                                [15
                                                                                  and prints all the factors of the number smaller than itself.
          Define a class that accepts an integer
                                                                              n
          For example: 8 as input gives
             12         4       as outputs.