Xii 2021 22 t2 Assign It
Xii 2021 22 t2 Assign It
if( !a || ( b && c ) )
{
System.out.println("If executed");
}
else
{
System.out.println("else executed");
}
c) if( 1 > 2 )
{
System.out.println(" 1 is greater than 2");
}
d) if( 1 < 2 )
{
System.out.println("1 is less than 2");
}
else
System.out.println("2 is less than 1");
System.out.println("Hello From IfExample");
e) int marks = 80;
ayyappaschool.in
Sree Ayyappa Public School
Affiliated to Central Board of Secondary Education, Delhi
Sector V, Bokaro Steel City, Jharkhand - 827006
9234300650/ 91 6542 266491 [email protected]
f) int india_score = 300, pakistan_score = 290;
if( india_score > pakistan_score )
System.out.println("India Wins");
else
System.out.println("Pakistan Wins")
g) int a = 7 * 3 + 6 / 2 - 5;
int b = 21 - 8 + a % 3 * 11;
if(a < b)
{
System.out.println("A is less than B");
}
if(a = b)
{
System.out.println("A is equal to B");
}
if(a > b)
{
System.out.println("A is greater than B");
}
h) int x = 20;
int y = 25;
if (++x < (y = y -= 4) || (x = x += 4) > y) {
System.out.println(x + "," + y);
}
i) int n = 5;
while( n > 0 ) {
n--;
System.out.println("n = " + n ); }
j)
int i = 1;
do {
System.out.println("Hello World");
i++;
}while (i < 6);
Q5. Briefly explain the following terms:
a) IDE b) Inspector Window c) Form d) JVM e) Data Encapsulation
f) Data members g) Class
Q6. Briefly define the use of the following methods:
a) setText b) setSelected c) setEnabled d) setVisible e) isEnabled f) isEditable g) setEditable
Q7. Differentiate between :
a) TextField and TextArea b) ComboBox and ListBox c) getText() and setText()
ayyappaschool.in
Sree Ayyappa Public School
Affiliated to Central Board of Secondary Education, Delhi
Sector V, Bokaro Steel City, Jharkhand - 827006
9234300650/ 91 6542 266491 [email protected]
Q8. What is Java Bytecode?
Q9. Explain the difference between a Class and an Object with an example.
Q10. Name any 4 primitive & Non-Primitive data types.
Q11. Design a GUI application to obtain the age of a person & display whether he/she is eligible
for voting. Make use of if statement only.
Q12. Write a code to test whether a given number in textfield is positive or not?
Q13. Create a GUI application to obtain Principal amount & time and then calculate simple
interest as per following specifications:
(If principal amount is greater than 10000, then rate of interest is 6% otherwise it is 5%.)
Q14. Write a code in java to test whether a number is positive or negative or zero.
Q15. Design an application that can test whether a temperature is freezing or not. It should be able
to test temperature for both Fahrenheit & Celsius scales.Use the temperatures 32º F and 0º C
as the freezing temperatures.
Q16. Write a program to obtain boiling point of water from user & report whether the user has
entered the correct answer or not. Make use of if…else statement.
Q17. Design a GUI application to accept age from the user in a text field and print using
JOptionPane whether the person is eligible for senior citizen benefits.
Q18. Design a GUI application to accept the cost price and selling price form the user in two text
fields then calculate the profit or loss incurred.
Q19. A networking company decided to computerize its employee salary. Develop an application
to store employee's personal data which will be saved in the back end. The front end should
accept Name, Father's Name, Gender, Basic Salary and Conveyance. Calculate the gross
salary.
Basic DA HRA
>=40000 35% 37%
>=20000 25% 32%
>=10000 25% 30%
ayyappaschool.in
Sree Ayyappa Public School
Affiliated to Central Board of Secondary Education, Delhi
Sector V, Bokaro Steel City, Jharkhand - 827006
9234300650/ 91 6542 266491 [email protected]
Q20. Rewrite the following program code using switch statement:
a) if (code == 'A') {
allowance = 3500;
}
else if (code == 'B') {
allowance = 3200;
}
else {
allowance = 2000;
}
b) int a=3;
if(a= =3) {
System.out.println(“Number is odd”); }
else if(a= =7) {
System.out.println(“Number is odd”);}
else if(a= =5) {
System.out.println(“Number is odd”); }
else if(a= =4){
System.out.println(“Number is even”);}
else{
System.out.println(“Number is not”);}
c) if( code == 1 ) {
Month = “January”; }
else if ( code == 2 ){
Month = “February”; }{
else if ( code == 3 )
Month = “March”;}
else if ( code == 4 ) {
Month = “April”;1}
Else{
Month = “No Match”;}
********
ayyappaschool.in