1.                   

Given  that  a =2 , b = 4 , c = 5

State  the  final  value  of  a  after  the  following  statement :

a += (--b) + ((c++) * (b--)) + b;                                                                             (1)

 

2.                   

Given  that  a =10 , b = 15

State  the  final  value  of  a  after  the  following  statement :

a += (b++) – ( a--)/2 + (a-4) + (b+a);                                                                   (1)

 

3.                  Given  that  x  = 5

State  the  final  value  of  x  after  the  following  statement :

x += (x++) + (--x) + 4;                                                                                          (1)

 

4.                   

The  following  function  sorts  an  integer  array  arr  in  ascending  order  using  the  Bubble  Sort  technique. Some  parts  of  the  function  have  been  replaced  by  n  where  n  is  from  1  to  5.  Fill  up  the  missing  parts  so  that  the  function  works  correctly :

 

public  void  sort( int  arr[] )

{

boolean swapped;

int t , j;

do

{

swapped =true;

for( ?1? ; ?2? ; j++)

         {

            if( arr[j] > ?3? )

                {

                swapped=false;

                t = arr[j];

                ?4?  = arr[j+1];

                arr[j+1]=t;

               }

       }

} while (  ? 5? );

}                                                                                                                             (5)

 

5.         Differentiate  between  the  statements  break  and  continue.                               (2)

 

6.         Consider  the  following  statement :

 

            String  ss  = “WELCOME”;

     

Write  a  single  line  statement  , using  the  new  operator , to  perform  the  above  task.

(1)

 

7.         State  one  advantage  and  one  limitation  of  the  switch-case  statement .         (2)

 

8.         The  following  integers  are  stored  in  an  array :

19    ,  12  ,  6 ,  40 , 3

 

The  array  is  to  be  sorted  in  ascending  order .  Describe  the  array  after  two  iterations 

using  :

 

a)                  Bubble  Sort  method

b)                  Selection  Sort  method                                                                                  (2+2)

 

9.         Observe  the  following  conditional  structure :

           

            if ( num < 10)

                           message = “ Single Digit  ”;

                        else if  ( num < 100 )

                           message = “ Double Digit  ”;

                        else

                           message = “ Triple Digit or  more  ”;

 

                        Write  a  single  line  of  code  using  the  ternary  operator  to  perform the

                        same  task .                                                                                                    (2)

 

10.       How  is  the  size  of  an  object  determined ?                                                         (1)

 

 

 

 

 

 

 

 

Hosted by www.Geocities.ws

1