Page 466 - Computer science 868 Class 12
P. 466

3         ArrayB(int x[]) // parameterised constructor

                 4         { for(int i=0;i<10;i++)
                 5           { arr[i]=x[i];}
                 6         }

                 7         boolean searcharray(int n)
                 8         { for(int i=0;i<10;i++)

                 9           { if(arr[i]==n) // if found
                10              return true;

                11           }
                12             return false; // not found if it reaches here

                13           }
                14       }

                15
                16       class ArrayD extends ArrayB

                17       {
                18         ArrayD(int x[]) // parameterised constructor

                19         { super(x);
                20         }

                21         boolean searcharray(int x,int y)
                22         { int c=0;

                23           for(int i=0;i<10;i++)
                24           { if(arr[i]>x && arr[i]<y) // if true

                25               c=c+1;
                26           }
                27           if(c==10) //if all 10 elements satisfy condition

                28             return true;

                29           else
                30             return false; // not found if it reaches here
                31       }

                32       void display()
                33       { for(int i=0;i<10;i++)

                34           System.out.print(arr[i]+" ");
                35           System.out.println();

                36       }




                464464  Touchpad Computer Science-XII
   461   462   463   464   465   466   467   468   469   470   471