|
Question 4 :
(a) What will be the content of jTextArea1 and jTextField1 after the execution of the following statement?
(i) jTextArea1.setText(“JusttAnothernDay”);
(ii) String Subject = “Informatics Practices”;
jTextField1.setText((Subject.length() +10)+ “ “);
(b) Rewrite the following programme code using a if statement:
������ String Remarks;
������ int Code= Integer.parseInt(jTextField1.getText());
������ switch(Code)
������ {
������������� case 0: Remarks = “100% Tax Exempting”;
������ �������������������� �������������������� break;
������������� case 1: Remarks = “50% Tax Exemption”;
����������������������������������������������� break;
������������� case 2: Remarks� =”30% Tax Exemption”;
����������������������������������������������� break;
������������� default:� Remarks = “!Invalid Entry”;
� }
�
(c) Observe the following code carefully and find which statement will never get executed in the code?
������ int t=1;���������������������������������������� //Statement 1
������ do������������������������������������������������������� //Statement 2
������ {��������������������������������������������������������� //Statement 3
����������� if(t>13)������������������������������������������ //Statement 4
������������� jTextFiled1.setText(“Something”); //Statement 5
����������� else ����������������������������������������������� //Statement 6
������������� jTextFiled.setText(“Pass”);����������� //Statement 7
� � � � � � � t+=3;������������������������������� //Statement 8������������ ����
}����������������������������������������������������������� //Statement 9
while(t<=15);��������������������������������������� //Statement 10
�
(d) Write a java statement to make the jTextField1 non-editable.
(e) What will be displayed in jTextField1 and jTextField2 after the execution of the following code?
int LAST, First=3, Second=5;
Last= First+Second++;
jTextField1.setText(Integer.toString(Last));
jTextField2.setText(Integer.toString(Second));
�
(f) What will be the contents of Str1 and Str2 after the following code is executed?
String Str2, Str1;
Str= “Dear Friend”;
Str2=”Hello”;
Str1=Str2.concat(Str1);
������
(g) Aditya is a programmer at Edudel enterprises. He created the following GUI in NetBeans.

Help him to write code in Java for the following:
(i) To calculate Total marks obtained and display in jTextField4 on the click of command button “Get Total”.
(ii) To calculate Grade obtained and display in jTextField5 on the click of command button “Get Grade”. Criteria for Grade calculation is given below:
|
Marks
|
Grade
|
|
Above 80
|
A
|
|
Above 65 and <=55
|
B
|
|
Above 50 and <=65
|
C
|
|
<=50
|
D
|
�
�
�
�
�
(iii) To stop execution and exit from the application on the click of command button “Exit”.
[2+2+1+1+2+2+2+2+1=15]
|
No comments:
Post a Comment