abstract class X {

Document Sample
abstract class X { Powered By Docstoc
					‫ﻱﻭﺮﺴﺧ ﻦﻴﺘﻣﺍﺭ :ﺱﺭﺪﻣ‬                                                             ‫ﺍﻭﺎﺟ ﻲﺴﻳﻮﻧﻪﻣﺎﻧﺮﺑ ﻝﺎﺳﻢﻴﻧ ﻥﺎﻴﻣ ﻥﺎﺤﺘﻣﺍ‬
‫ﺖﻋﺎﺳ ۲ ﻥﺎﺤﺘﻣﺍ ﺕﺪﻣ‬                                                                                                       ‫۸ ۳ ﺰ ﻴﻳ ﺎﭘ‬




                    ‫.ﺪﻴﻫﺩ ﻞ ﻳﻮﺤﺗ ﺩﻮﺧ ﺦﺳﺎﭘ ﻪ ﭼﺮﺘﻓﺩ ﻩﺍﺮﻤﻫ ﺍﺭ ﻥﺁ ﻭ ﺪﻴﻫﺩ ﺦ ﺳﺎﭘ ﻝﺍﺆﺳ ﻪﮔﺮﺑ ﺭﺩ ۳ ﻭ ۲ ﻱﺎﻫ ﻝﺍﺆﺳ ﻪﺑ‬


                                             ‫:ﻲﻳﻮﺠﺸﻧﺍﺩ ﻩﺭﺎﻤﺷ‬                                             ‫:ﻲﮔﺩﺍﻮﻧﺎﺧ ﻡﺎﻧ ﻭ ﻡﺎﻧ‬


     ‫ﻱﺍﺮﺑ ﻭ ﻢﻳﺩﺮﮐ ﻒﻳﺮﻌﺗ‬
                     ‫‪private‬‬           ‫ﺍﺭ ﻪﻴﻧﺎﺛ ﻭ ﻪﻘﻴﻗﺩ ،ﺖﻋﺎﺳ ﻱﺎﻫﺪﻠﻴﻓ ،ﺎﻫ ﺱﻼﮐ ﻒﻳﺮﻌﺗ ﺭﺩ ﺞﻳﺍﺭ ﺵﻭﺭ ﻖﺒﻃ ، ﺱﻼﮐ ﻒﻳﺮﻌﺗ ﺭﺩ -(ﻩﺮﻤﻧ ۲)‬
                                                                                       ‫‪Time‬‬                            ‫۱ ﻝﺍﺆﺳ‬

‫.ﺪﻴﻨﮐ ﺮﮐﺫ ﻢﻴﻨﮐ ﻒﻳﺮﻌﺗ‬           ‫ﺍﺭ ﺎﻫﺪﻠﻴﻓ ﻪﮐ ﻲﺘﻟﺎﺣ ﻪﺑ ﺖﺒﺴﻧ ﺍﺭ ﺵﻭﺭ ﻦﻳﺍ ﻱﺍﺮﺑ ﺖﻳﺰﻣ ﻭﺩ .ﻢﻳﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻭ ﻱﺎﻫﺪﺘﻣ ﺯﺍ ﺎﻬﻧﺁ ﻪﺑ ﻲﺳﺮﺘﺳﺩ‬
                          ‫‪public‬‬                                                           ‫‪get set‬‬


                                                           ‫.ﺪﻴﻨﮐ ﺺﺨﺸﻣ ﺮﻳﺯ ﻱﺎﻫ ﺱﻼﮐ ﺭﺩ ﺍﺭ ﻪﻤﺟﺮﺗ ﻥﺎﻣﺯ ﯼﺎﻄﺧ ﻪﺳ -(ﻩﺮﻤﻧ ۳)‬   ‫۲ ﻝﺍﺆﺳ‬


      ‫{ ‪abstract class X‬‬
          ‫}{ )‪private void f(int i‬‬
          ‫}{ )(‪public void g‬‬
          ‫}{ )(‪public void h‬‬
          ‫;)(‪public abstract void m‬‬
      ‫}‬

      ‫{ ‪class Y extends X‬‬
          ‫} ;0 ‪public int f(int i) { return‬‬
          ‫}{ )(‪void g‬‬
          ‫}{ )‪public void h(int i‬‬
      ‫}‬

      ‫{ ‪class Z extends Y‬‬
          ‫} ;0 ‪public int h() { return‬‬
          ‫}{ )(‪public void m‬‬
      ‫}‬

                                        ‫؟ﺖﺴﻴﭼ‬   ‫)(‪new Y().k‬‬     ‫ﻪﺠﻴﺘﻧ ﺮﻳﺯ ﻞﮑﺷ ﻪﺑ ﻭ ﻱﺎﻫ ﺱﻼﮐ ﻦﺘﺷﺍﺩ ﺽﺮﻓ ﺎﺑ -(ﻩﺮﻤﻧ ۴)‬
                                                                               ‫‪Y X‬‬                                     ‫۳ ﻝﺍﺆﺳ‬


      ‫{ ‪class X‬‬
          ‫;91 = ‪private int i‬‬
          ‫;76 = ‪public int j‬‬

           ‫} ;21 = ‪public X() { i‬‬
               ‫} ;)‪{ System.out.println(i‬‬
           ‫} ;‪private void f() { j = i‬‬
           ‫} ;63 = ‪protected void g() { i‬‬
           ‫{ )(‪public void h‬‬
               ‫;)(‪f‬‬
               ‫;)(‪g‬‬
           ‫}‬
      ‫}‬

      ‫{ ‪class Y extends X‬‬
          ‫;6 = ‪private int i‬‬
          ‫} ;++‪private void f() { i‬‬
          ‫} ;--‪protected void g() { i‬‬
          ‫{ )(‪public void k‬‬
              ‫;)(‪h‬‬
              ‫;)‪System.out.println("i = " + i + ", j = " + j‬‬
          ‫}‬
          ‫} ;)‪{ System.out.println(j‬‬
      ‫}‬
                                                                                                                                                                ‫ﺪﻴﺷﺎﺑ ﻖﻓﻮﻣ‬
‫ﻒﻳﺮﻌﺗ ﺭﺩ‬   ‫‪cnuFddA‬‬     ‫ﭗﻳﺎﺗ ﺯﺍ ﻲﺳﻼﮐ ﺮﻫ ﻉﻮﻧ ﺯﺍ ﻥﺁ ﺓﺪﻧﺯﺎﺳ ﻱﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﻪﮐ ﺪﻴﻨﮐ ﺖﻗﺩ‬                      ‫‪c n u F ht a M‬‬   ‫ﻉﻮﻧ ﺯﺍ ﻂﻘﻓ ﻪﻧ ﻭ ﺪﻨﺷﺎﺑ ﺪﻨﻧﺍﻮﺗﻲﻣ‬   ‫‪laimonyloP‬‬      ‫.‬
                           ‫0.8 ‪// prints‬‬                                        ‫;))3(‪System.out.println(a.derivative().evaluate‬‬
                           ‫0.71 ‪// prints‬‬                                       ‫;))3(‪System.out.println(a.evaluate‬‬
                                                                                ‫;))(‪AddFunc a = new AddFunc(p, p.derivative‬‬
‫:ﺩﺯ ﻝﺎﺜﻣ ﺍﺭ ﺮﻳﺯ ﺪﮐ ﻪﻌﻄﻗ ﻥﺍﻮﺗﻲﻣ ﻒﻟﺍ ﺖﻤﺴﻗ ﺪﮐ ﻪﻌﻄﻗ ﻦﺘﺷﺍﺩ ﺽﺮﻓ ﺎﺑ ،ﻪﻧﻮﻤﻧ ﻥﺍﻮﻨﻋ ﻪﺑ .ﺪﻨﺘﺴﻫ ﺮﮕﻳﺩ ﻊﺑﺎﺗ ﻭﺩ ﻥﺁ ﻱﺎﻫﺮﺘﻣﺍﺭﺎﭘ‬
‫(ﺏ‬    ‫ﻡﺎﻧ ﻪﺑ ﻲﺳﻼﮐ‬  ‫‪cnuFddA‬‬   ‫ﻂﺳﺍﻭ ﻪﮐ ﺪﻴﻨﮐ ﻒﻳﺮﻌﺗ‬                 ‫‪c n u F ht a M‬‬
                                                               ‫ﻪﮐ ﺩﺭﺍﺩ ﻩﺪﻧﺯﺎﺳ ﮏﻳ ﺱﻼﮐ ﻦﻳﺍ .ﺪﺷﺎﺑ ﺮﮕﻳﺩ ﻊﺑﺎﺗ ﻭﺩ ﻊﻤﺟ ﺎﺑ ﻝﺩﺎﻌﻣ ﻭ ﺪﻨﮐ ﻱﺯﺎﺳﻩﺩﺎﻴﭘ ﺍﺭ‬
‫ﺕﺭﺎﺒﻋ ﺯﺍ ﺍﻭﺎﺟ ﺭﺩ ﺔﺒﺳﺎﺤﻣ ﻱﺍﺮﺑ‬
              ‫‪xy‬‬                      ‫)‪Math.pow(x, y‬‬                    ‫.ﺪﻴﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ‬
                           ‫0.6 ‪// prints‬‬                                        ‫;))3(‪System.out.println(p.derivative().evaluate‬‬
                           ‫0.11 ‪// prints‬‬                                       ‫;))3(‪System.out.println(p.evaluate‬‬
                                                                                ‫;)‪Polynomial p = new Polynomial(c‬‬
                                                                                ‫;}1,0,2{ = ‪double[] c‬‬
                   ‫‪p‬‬
‫ﻱﺍﻪﻠﻤﺟﺪﻨﭼ ﻝﺩﺎﻌﻣ ،ﻝﺎﺜﻣ ﻦﻳﺍ ﺭﺩ .ﺖﺳﺍ‬         ‫.ﺖﺳﺍ‬    ‫2 + 2‪x‬‬
‫ﺮﻳﺯ ﻞﮑﺷ ﻪﺑ ﺱﻼﮐ ﻦﻳﺍ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺯﺍ ﻱﺍﻪﻧﻮﻤﻧ .ﺖﺳﺍ ﻩﺪﺷ ﻩﺮﻴﺧﺫ ﻪﻳﺍﺭﺁ ﺲﮐﺪﻨﻳﺍ ﺭﺩ ﺐﻳﺮﺿ ﻪﮐ ﻱﺭﻮﻃ ﺪﻨﺘﺴﻫ ﻱﺍﻪﻠﻤﺟﺪﻨﭼ ﺐﻳﺍﺮﺿ ﻱﻭﺎﺣ ﻥﺁ ﺮﺘﻣﺍﺭﺎﭘ‬
                                                                            ‫‪xi‬‬              ‫‪i‬‬
‫(ﻒﻟﺍ‬   ‫ﻡﺎﻧ ﻪﺑ ﻲﺳﻼﮐ‬     ‫‪laimonyloP‬‬
                               ‫ﻪﮐ ﺩﺭﺍﺩ ﻩﺪﻧﺯﺎﺳ ﮏﻳ ﺱﻼﮐ ﻦﻳﺍ .ﺪﺷﺎﺑ ﻱﺍﻪﻤﻠﺟﺪﻨﭼ ﮏﻳ ﺎﺑ ﻝﺩﺎﻌﻣ ﻭ ﺪﻨﮐ ﻱﺯﺎﺳﻩﺩﺎﻴﭘ ﺍﺭ ﻕﻮﻓ ﻂﺳﺍﻭ ﻪﮐ ﺪﻴﻨﮐ ﻒﻳﺮﻌﺗ‬
‫.ﺖﺳﺍ ﻪﻴﻟﻭﺍ ﻊﺑﺎﺗ ﻖﺘﺸﻣ ﻝﺩﺎﻌﻣ ﻪﮐ ﺪﻧﺍﺩﺮﮔﻲﻣﺮﺑ ﺀﻲﺷ‬
‫ﺪﺘﻣ .ﺖﺳﺍ ﻩﺪﺷ ﻒﻳﺮﻌﺗ ﻩﺮﻴﻐﺘﻣ ﮏﺗ ﻲﺿﺎﻳﺭ ﻊﺑﺍﻮﺗ ﭗﻳﺎﺗ ﻥﺍﻮﻨﻋ ﻪﺑ ﻂﺳﺍﻭ ﻦﻳﺍ‬                    ‫‪e t a ul a v e‬‬   ‫ﺪﺘﻣ .ﺪﻨﮐﻲﻣ ﻲﺑﺎﻴﺷﺯﺭﺍ ﺮﺘﻣﺍﺭﺎﭘ ﺭﺍﺪﻘﻣ ﻱﺍﺯﺍ ﻪﺑ ﺍﺭ ﻊﺑﺎﺗ‬   ‫‪e vi t a vi r e d‬‬   ‫ﮏﻳ‬
                                                                                                    ‫}‬
                                                                                                        ‫;)(‪public MathFunc derivative‬‬
                                                                                                        ‫;)‪public double evaluate(double x‬‬
                                                                                                    ‫{ ‪public interface MathFunc‬‬
‫۵ ﻝﺍﺆﺳ‬     ‫) ﻂﺳﺍﻭ – (ﻩﺮﻤﻧ ۶)‬   ‫‪e c a f r e t ni‬‬   ‫:ﺪﻳﺮﻴﮕﺑ ﺮﻈﻧ ﺭﺩ ﺍﺭ ﺮﻳﺯ (‬
                                                      ‫0‬     ‫1‬       ‫0‬       ‫1‬                         ‫1‬     ‫0‬        ‫1‬     ‫1‬
                                                      ‫0‬     ‫0‬      ‫1‬        ‫1‬                         ‫0‬     ‫1‬        ‫0‬     ‫1‬
                                                      ‫1‬     ‫1‬      ‫0‬        ‫1‬                         ‫1‬     ‫1‬        ‫1‬     ‫0‬
                                                      ‫1‬     ‫0‬      ‫1‬        ‫0‬                         ‫0‬     ‫0‬        ‫0‬     ‫1‬
                                                     ‫‪true‬‬
‫ﺭﺍﺪﻘﻣ ﻪﻧﺮﮔﻭ ﺭﺍﺪﻘﻣ ،ﺩﻮﺑ ﻝﺎﺣﺎﺑ ﺲﻳﺮﺗﺎﻣ ﺮﮔﺍ ﻭ ﺩﺮﻴﮕﺑ ﺮﺘﻣﺍﺭﺎﭘ‬                     ‫‪false‬‬
                                                                    ‫.ﺪﻧﺍﺩﺮﮔﺮﺑ‬
‫ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺲﻳﺮﺗﺎﻣ ﮏﻳ ﻪﮐ ﺪﻴﺴﻳﻮﻨﺑ ﻱﺪﺘﻣ .ﺖﺴﻴﻧ ﺭﻮﻃ ﻦﻳﺍ ﻲﺘﺳﺍﺭ ﺖﻤﺳ ﻲﻟﻭ ﺖﺳﺍ ﻝﺎﺣﺎﺑ ﭗﭼ ﺖﻤﺳ ﺲﻳﺮﺗﺎﻣ ،ﺮﻳﺯ ﻞﮑﺷ ﺭﺩ ﹰﻼﺜﻣ .ﺖﺳﺍ ۱ ﺰﻴﻧ ﻥﺁ ﺖﺳﺍﺭ‬
‫۴ ﻝﺍﺆﺳ‬     ‫ﺖﻤﺳ ﺔﻳﺍﺭﺩ ﻪﮐ ﺩﻮﺷ ﺖﻓﺎﻳ ۱ ﺔﻳﺍﺭﺩ ﮏﻳ ﻞﻗﺍﺪﺣ (ﺮﺧﺁ ﻥﻮﺘﺳ ﺰﺟ ﻪﺑ) ﻥﺁ ﻥﻮﺘﺳ ﺮﻫ ﺭﺩ ﺮﮔﺍ ﻢﻴﻣﺎﻧ ﻲﻣ ﻝﺎﺣﺎﺑ ﺍﺭ ﮏﻳ ﻭ ﺮﻔﺻ ﺯﺍ ﻲﺴﻳﺮﺗﺎﻣ -(ﻩﺮﻤﻧ ۵)‬