Code: DC-12                                                                                     Subject: OOPS THRU JAVA

Time: 3 Hours                                                                                                     Max. Marks: 100

NOTE: There are 11 Questions in all.

·      Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the boxes provided on page 1. Tear this sheet and attach it to the main answer book.

·       Answer any THREE Questions each from Part I and Part II.

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

                        

ROLL NO.

 

 

Q.1            State which of the statement is true and which are false. (Tick the box)            (2x8)

a.       Encapsulation is the mechanism that binds together code & the data it manipulates & keeps  both safe from outside interference & misuse.

TRUE

 

FALSE

 
         

 

b.      An array is a group of liked-typed variables that are referred by a common name.

TRUE

 

FALSE

 
 

 


c.       Classes usually consist of two things: instance variable & constants.

TRUE

 

FALSE

 
                                                                                   

                  

 

 

d.      Method overloading is one of the ways that Java implements polymorphism.

FALSE

 

TRUE

 
        

 

 

e.       A class member that has been declared as private will remain private  

                   to its class.

FALSE

 

TRUE

 
          

 

 

f.        The package statement defines a name space in which object are stored.

TRUE

 

FALSE

 
 


       

 

g.       The general form of throw is :-

                    throw    ThrowableInstance;

TRUE

 

FALSE

 
 

 


             h.  The file Input Stream class creates an Input Stream that you can use to write bytes from a file.

TRUE

 

FALSE

 
 

 


            

CENTRE STAMP                

 

                                                                                                Signature of Suptd/invigilator

 
 

 

 

 

 

 

 

 


PART I

Answer any THREE Questions. Each question carries 14 marks.

  Q.2     a.   Define the following:                            

 (i)   throw & throws

 (ii)  Inheritance                                                                                                  (6)                                                                                             

 

b.    Write a program in Java to display the following on the screen:                           (8)

1

 

 

 

2

2

 

 

3

3

3

 

4

4

4

4

         

                                             

 

                                                                               

 

  Q.3     a.   Differentiate between following:

(i)                  Bitwise AND & Bitwise OR

(ii)                Left Shift & Right Shift                                                                           (6)

                                       

b.      Why do we use explicit type conversion (cast)? Explain this with the help of an example.                 (8)       

                                                                              

  Q.4     a.   Write a program in Java by using “while loop” that counts down from 10, printing exactly ten lines the string “IETE”.                                               (5)

 

             b.   How many jump statements does Java support?  Explain them in brief.                (9)

 

  Q.5     a.   Describe the different forms of inheritance with examples.                                   (4)

 

             b.   Define the following:

(i)                  this keyword

(ii)                finalize( ) method                                                                                   (4)

 

             c.   Define a class stack with push and pop operations.                                             (6)

 

  Q.6     a.    Differentiate between

                   (i)   Overloading Methods and Overloading Constructors.

                   (ii)  call-by-value and call-by-reference.                                                              (8)          

       

             b.   Define a class X.  Write a method which returns an object of class X.                 (6)

         

PART II

Answer any THREE Questions. Each question carries 14 marks.

 

  Q.7     a.   Write a recursive method printArray( ) that prints the first 8 elements in the array.               (8)

 

b.        Discuss the different levels of access protection available in Java.                       (6)  

            

  Q.8     a.   What is a nested class?  Explain the scope rules with the help of an example.                      (8)

 

             b.   Why do we use command-line arguments? Justify your answer.                           (6)

            

  Q.9     a.   Can we reference a subclass object by a superclass variable?  Explain with the help of an example.                                                            (7)

 

b.      What are the two general forms of super?  Explain.                                            (7)

 

Q.10           a.                                                        Define the following:

 

(i)                  Extending Interfaces.

(ii)                Implementing Interfaces.                                                                   (6)

 

             b.   Define package with the help of a suitable example.                                            (8)

            

Q.11           a.                                                        Explain the meaning of the following built-in exceptions in Java

 

(i)                  ArrayStoreException.

(ii)                ArithmeticException.

(iii)               ClassCastException.                                                                        (6)

 

             b.   Write a program to copy characters from one file into another.                            (8)