K V NO.I KANCHRAPARA

WINTER HOLIDAY HOMEWORK 2015-16

CLASS-XI Comm.. SUBJECT- IP

JAVA

Q1) Write Java code that takes the cost of a pencil from jTextField1 and number of pencils from jTextField2 and calculates total amount as cost *number to be displayed in jTextField3 and 20% service tax out of total amount in jTextField4.

Q2) What will be displayed in of jTextField1 after executing the following code?

int m = 16;

m = m+1;

if (m < 15 )

jTextField .setText (Integer . tostring (m));

else

jTextField1.setText (Integer.toString (m+15));

Q3) Rewrite the following program code using a Switch statement:

If (code == 1)

Month = “January”;

else if (code == 2)

Month = “February”;\

else if (code == 3)

Month = “March”;

else if (code == 4)

Month = “April”;

else

Month = “No Match”;

Q4) What will be displayed in jTextArea1 after executing the following statement ?

jTextArea1 .setText (“cbse\nFinal_Exam\tIp”);

Q5) The following code has some error(s). Rewrite the correct code underlining all the corrections made:

int Sum=0, step=5;

int I;

for(i = 0, i =< 5 , i++)

{

Step+=5;

Sum+=Step;

}

jTextAreal.showText(“ “+Sum);

Q6) The students of “ShikshaVidyalaya “ work for different extra-curricular activities like ‘Community Outreach Programme’ , ‘Swachh Bharat Abhiyan ‘ and ‘Traffic Safety Club’. The Programmer at the school has developed a GUI application as shown below:

·  A student can take part in more than one activities.

·  Each student gets 10 points for each activity – namely Community Outreach Programme, Swachh Bharat Abhiyan and Traffic Safety Club.

Help the programmer to write the code for the following:

(i)  When ‘Calculate Total Score’ button is clicked, the points for each activity (that is selected) should be displayed in the text field in front of that activity’s checkbox and the Total Score should be displayed in the appropriate text field.

(ii)  When Clear button is clicked, all the Textfields and Checkboxes should be cleared.

(iii)  When Stop button is clicked, the application should close.