Page 43 - IP
P. 43

(b)     Prachi is working with following swing controls:                               1

                         jButton, jLabel, jTextField, jCheckBox.

                         Suggest  her  any  two  basic  methods  commonly  available  with  all  the  four
                         controls mentioned above.
                                                              OR

                         How jLabel is different from jTextField control at run time?

                  Ans:  getText(), setText()
                         (½ Mark for each correct answer)

                                                              OR

                         jLabel is an un-editable control, used to display text or information at run time
                         while jTextField control is an editable control where user can type in characters
                         at run time.

                         (1 Mark for correct answer)

                  (c)     What will be an output of the following code if value of variable application is 1?  1
                         switch(application)
                                   {
                         case 0    :  jTextField1.setText("RDBMS");
                         case 1    :  jTextField1.setText("BROWSER");
                         case 2    :  jTextField1.setText("OS"); break;
                         case 3    :  jTextField1.setText("PHOTO EDITOR"); break;
                         default  :  jTextField1.setText("Application Software"); break;
                                   }
                                                              OR

                         Re-write the above given code through if-else statements.

                  Ans:  OS

                         (1 Mark for correct answer)
                                                              OR

                         if(application= =0)
                                   jTextField1.setText("RDBMS");
                         else if(application= =1)
                                   jTextField1.setText("BROWSER");
                         else if(application= =2)
                                    jTextField1.setText("OS");
                         else if(application= =3)
                                    jTextField1.setText("PHOTO EDITOR");
                         else
                                   jTextField1.setText("Application Software");

                         (1 Mark for correct converted code)




                                                            6
   38   39   40   41   42   43   44   45   46   47   48