Page 56 - IP
P. 56
PREBOARD
EXAMINATION
(e) What will be the contents of jTextField1 and jTextField2 after executing the following code: 2
String str =”Mahatma”;
jTextField1.setText(str.substring(4));
jTextField2.setText( “” +str.length(
));
(f) The following code has some error(s).Rewrite the correct code underlining all corrections made.
2
int i = 2, j = 5;
while j >i
{
jTextField1.getText(“j is greater”); j --;
++I;}
joptionpane.showMessageDialog(“Hello
”);
(g) ABC School uses the following interface built in java to check the eligibility of a student for a particular
stream from science, commerce and humanities. The user first enters the total percentage and selects the
desired stream by selecting the appropriate option button. An additional 5% is marks is given to students of
NCC.
Write Java Code for the following
a) On the Action event of the close button the application gets closed. 1
b) On the Action event of the clear button all the text fields and the check boxes get cleared. 1
c) On Action event of the button ‘Calc Percentage’ Net percentage of the student is calculated and
displayed in the appropriate text filed. Net percentage is same as that of the actual percentage if
the student doesn’t opts for NCC otherwise 5% is added to actual percentage. 2
d) On Action Event of the button ‘Result’, the application checks the eligibility of the students.
And display result “ in the appropriate text field. Minimum percentage for science is 70, for
commerce 60 and for humanities 40. 2