Page 456 - Computer science 868 Class 12
P. 456
9 protected void findhighest()
10 { for(int i=0;i<10;i++)
11 { h=Math.max(h,a[i]);}
12 }
13 void display()
14 { System.out.println("The array is");
15 for(int i=0;i<10;i++)
16 { System.out.print(a[i]+" ");}
17 System.out.println("\nHighest="+h);
18 }
19 }
20 class SecondH extends Highest
21 { int sh;
22 SecondH(int x[])
23 { super(x);
24 sh=a[0];
25 }
26 void findsecond()
27 { findhighest();
28 for(int i=0;i<10;i++)
29 { if(a[i]<h && a[i]>sh)
30 sh=a[i];
31 }
32 }
33 void display()
34 { super.display();
35 System.out.println("Second highest ="+sh);
36 }
37 public static void main(int ar[])
38 { SecondH ob=new SecondH(ar);
39 ob.findsecond();
40 ob.display();
41 }
42 }
454454 Touchpad Computer Science-XII

