Flowchart: Alternate Process: JUNE 2008

Code: DC12                                                                                      Subject: OOPS THRU JAVA

Time: 3 Hours                                                                                                     Max. Marks: 100

 

NOTE: There are 9 Questions in all.

·      Question 1 is compulsory and carries 20 marks. Answer to Q. 1. must be written in the space provided for it in the answer book supplied and nowhere else.

·      Out of the remaining EIGHT Questions answer any FIVE Questions. Each question carries 16 marks.

·      Any required data not explicitly given, may be suitably assumed and stated.

 

 

 

Q.1       Choose the correct or best alternative in the following:                                         (2x10)

              

a.          JDK is product of ____________

 

        (A)  IBM                                          (B)  Sun Micro Systems

        (C)  Microsoft                                  (D)  ORACLE INC

 

b.         Consider the following statements:

           int x = 10, y = 15;

           X = (x < y) ? (y + x) : (y – x) 

               What will be the value of X after executing these statements?

        (A)  10                                             (B)  25

        (C)  15                                             (D)  5

 

c.          Consider the following class definition

           class Student extends String

           {

           }

           What happens when we try to compile this class?

 

        (A)  Will not compile because class body is not defined.                                       

        (B)  Will not compile because class is not declared public.

        (C)  Will not compile because String is abstract.                                                   

        (D)  Will not compile because String is final.

 

d.         Which of the following are keywords?

 

        (A)  switch                                       (B)  integer

        (C)  character                                   (D)  object

 

e.          Which keyword can protect a class in a package from accessibility by the classes outside the package?

       

        (A)  private                                                                                                          

        (B)  protected

        (C)  final

        (D)  don’t use any keyword at all (make it default)                                               

 

f.           A package is a collection of

 

     (A)  classes                                      (B)  interfaces

     (C)  editing tools                              (D)  classes and interfaces

 

g.          Which of the following methods belong to the String class?

 

        (A)  length( )                                     (B)  compareTo( )

(C)    equals( )                                    (D)  All of them                                           

 

h.          Which of the following command line options generates documentation for all classes and method?

 

        (A)  -protected                                 (B)  -public

        (C)  -private                                     (D)  -verbose

 

i.            Which of the following statements are valid array declaration?

(A)     int number ( );                           (B)  float average [ ];

        (C)  [ ] double marks;                       (D)  counter int [ ];

 

j.           Two methods in a class one overloaded if

 

        (A)  they have same parameters        

        (B)  they have same number of arguments

        (C)  they have same return type         

        (D)  they have same name

 

 

 

 

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   Explain various features of Java that make it suitable for Internet.                         (8)

 

             b.   Assume that a bank maintains two kinds of account for its customers, one called savings account and the other current account. The savings account provides simple interest. Calculate account holders should also maintain a minimum balance of Rs.1000/- and if the balance falls below this level, Rs.20/- is deducted from the account.

                   Create a class Account that stores customer name, account number and balance. From this derive the class Curracct and Savacct to make them more specific to their requirements. Include the necessary methods in order to achieve the following tasks:

                   (i) Compute and deposit interest in Savacct.

                   (ii) Check for the minimum balance, impose penalty, if necessary, and update the balance in Curracct.                                                                   (8)

 

  Q.3     a.   What do you understand by dynamic method dispatch? Explain with the help of an example.                                                                      (8)

 

             b.   What do you mean by Literals?  Explain any eight character escape sequences used as Literals in Java.                                                                  (8)

                                                                                                                                                           

  Q.4     a.   How the data types are converted between incompatible using the cast?  Give example.                 (8)

                  

            

             b.   Write a program in Java which produce the following output

                                    1

                                    2       2

                                    3       3       3

                                    4       4       4       4

                                    5       5       5       5       5                                                                   (8)          

 

  Q.5     a.   What is garbage collection in Java?                                                                     (4)

 

b.      Explain with example the difference between X++ and ++X.                               (4)

 

             c.   Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7 using for and if loop.        (8)

 

  Q.6     a.   Write a program using recursion to calculate and print the first n Fibonacci numbers.  The number of the sequence 1, 1, 2, 3, 5, 8, 13, 21 …… are called Fibonacci numbers.                                 (8)

            

             b.   Explain the use of three-way operator “?” used in Java.  Write a program to obtain the absolute value of a variable.                                              (8)

                  

  Q.7     a.   Create a class named Box with suitable parameter and write a method to compute the volume of Box.                                                                   (8)

 

             b.   What is Method overloading?  Explain with the help of example.                         (8)

                  

  Q.8     a.   What is Inheritance?  Differentiate between a sub class and super class.  Write a program which inherits the class box  and also make a sub class with forth component weight . (10)

       

             b.   Describe the aspect of polymorphism as allowed by the keyword “interface”.  Explain the syntax for defining an interface.                                         (6)

 

  Q.9     a.   What are the uncaught exceptions?  Show by example how an exception can handled using try and catch method.                                               (8)

 

             b.   Write short notes on the following:

 

(i)         The Predefined Streams.

(ii)        Printer Writer class.                                                                            (4  2)