DipIETE – CS (OLD SCHEME)

 

Code: DC12            Subject: OBJECT-ORIENTED PROGRAMMING THROUGH JAVA

Flowchart: Alternate Process: JUNE 2010Time: 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 the best alternative in the following:                                (210)

       

a.          What will be the values of x, m  and n after execution of the following statements:

         int x,m,n;

         m=10,n=15;

         x=++m + n++;

 

        (A)  x=25, m=10, n=15                   (B)  x=27, m=10, n=15

        (C)  x=26, m=11, n=16                   (D)  x=27, m=11, n=16

 

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.          The use of ‘Final’ keyword in Java are _________.

 

        (A)  to handle exception                

        (B)  to prevent Overriding and Inheritance

        (C)  to implement Abstract class   

        (D)  None of the above.                 

 

d.         In Java objects passed to a method by use of ________________.

 

        (A)  call by value method               (B)  call by reference method

        (C)  recursive method                     (D)  None of the above.                             

 

e.          The code in the _______ block is executed irrespective of whether an exception is raised or not.

 

        (A)   try                                           (B)  catch

        (C)  finally                                      (D)  All of the above.

 

 

f.          All Exception types are subclasses of the built in class ___________.

 

     (A)  Runtime Exception class         (B)  Throwable class

     (C)  Cast Exception class               (D)  Error class

 

g.         The ____________ is the super class for all the classes in Java.

 

        (A)  Object class                             (B)   System class

        (C)  String class                              (D)  All of the above

 

h.         When you implement an interface, it must be declared as __________.

 

        (A)  private                                      (B)   public

        (C)  protected                                 (D)   None of the above.

 

i.           A package is a collection of ___________.

 

        (A)  interfaces                                 (B)   classes

        (C)  editing tools                             (D)   classes and interfaces

              

j.           The ____________ method is called just before the browser is shut down.

 

        (A)  Stop( ) method                        (B)  Start( ) method

        (C)  Destroy( ) method                   (D)  All of the above.

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   Discuss the features of Java.                                                                            (6)

 

             b.   List the eight basic data types in Java.                                                             (5)

 

             c.   What is class? What are the rules for naming classes?                                     (5)          

                                                                                                                                                

  Q.3     a.   What is Constructor? Explain with example and also its characteristics.        (8)

                

           b.   Write a program in Java to generate the following output:                                 

                 1   4   9   16   25                                                                                              (8)

          

  Q.4     a.   Explain the use of “Super” keyword. Use “Super” in a program to call super class constructor.                                                                      (8)

                  

             b.   Explain dynamic method dispatch with example.                                           (8)

       

  Q.5     a.   Write a program in Java for the following:                                                      (8)

                                         1

                                         22

                                        333

 

 

b.      Explain the following with example:

(i)  for loop

(ii) do-while loop                                                                                             (8)

                  

Q. 6     a.   What is Java Applet?  How can we execute Applet?                                      (7)

       

             b.   How can we differentiate Java Applet from Java Application?                      (3)

                  

             c.   Find the output of the following program                                                       (6)

                                    class Rec

{

public static void main (String args[ ])

{

int R =abc (10);

System.out.println(Result=+R);

}

static int abc (int m)

{

if(m<=2)

return m;

else

return m+ abc(m-2);

}

}

       

  Q.7     a.   Discuss the rules for coding the main( ) method in Java.                                (6)

 

             b.   Explain the two ways of passing arguments to a method in java with examples.                       (10)

 

  Q.8     a.   What is an exception? What is the need for exception handling and discuss exception handling mechanism with examples.                (10)

                  

             b.   Find the output of the following statements:

                                    int x=10, y,z;

                                    y=x>15;

z=((x<15)?100:200);

System.out.println(y=+y);

System.out.println(z=+z);                                                         (6)

 

  Q.9           Writes short notes on the following:                                                         (4  4)

 

(i)                 Interfaces.

(ii)               Packages.

(iii)             Printer Writer Class.

(iv)             The predefined streams.