Java Assignment XI & XII (IT 802 Code)
Java Assignment XI & XII (IT 802 Code)
*/
5. Write Java code to assign the value 70
variable y. Then decrease the value of y by 5
and store it in variable z.
Ans. int y=70;
int z=y-5;
6. Write the value of t after the execution of the
following code:
int t;
int s;
s=6;
t=(8* ++s) / 7;
or
t=(8* ++s) % 7;
Ans 8
or
0
7. The expression 10%3 evaluates
to _____ Ans 1
8. What will be the result of A=7/3 ,
If a is- (a) float (b) int
Ans (a) 2.33
(b) 2
9. What Kind of constants are the following-
14, 011, 0x2A, 17, 079, 0xBC, 899.90
int , Octal, Hexa Dec, Int Octal Hexa Dec,
Double
10. What is the difference between
'a' and "a" in Java?
11. _______ method shows a one-
button, modal dialog box that gives
the user some information
Ans. JOptionPane.showMessageDialog();
12. Method which set the jButton
enable or disable is:
Ans.setEnabled
13. Write down any one function of
JoptionPane.
Ans.JOptionPane.showMessageDialog(null," "+
);
14. Double quotest " " is used to
enclose ____ data type.
Ans.String
15. Single quotes ' ' is used to
enclose ____ data type.
Ans.char
16. The Arithmetic Operator which
returns remainder as result is:
(a) / (b) *
(c) % (d) None of these
17. If((a<10) && (a>20))
(a) Test condition will always be false
(b) Test condition will always be true
(c) The Test Condition will depend on the value
of a
(d) None of these
18. Integer.parseInt() method is
used to:
(a) Convert Integer value to String value
(b) Convert an Integer to float
(c) Convert a value to Integer type
(d) Convert Integer value to Character type
19. How can you write multiline
comments in java program?
/* Java
Programming
*/
/
20. double.parseDouble() method is
used to:
(a) Convert Double value to String value
(b) Convert an Integer to float
(c) Convert a value to double type
(d) Convert Double value to Character type
Q. 21 Why main is special method
in java program?
Ans Main is a special method that every Java
application must have. When you run a
program, the statements in the main method
are the first to be executed.
23. What will be the value of n after the execution of the
following selection statement :
int n=0;
if (6>7 II 5>4)
{n=5;}
else n=7;
Ans. n=5
Q.24
What will be the value of rem after the execution of the following code
snippet? Give reason.
int code =2;
switch(code)
{ case 1: rem= 8;
case 2: rem= 9;
case 3: rem= 10; break;
case 4: rem= 11; break;}
Ans.
25. Write a program to check odd
no
int n=5;
if(n%2!=0)
System.out.println("No is Odd");
else
System.out.println("No is Even");
Q.26 Rewrite the following code using the if
statement without affecting the output of the
code:
char c;
String p;
switch(c){
case 'h' :p=”Shiv Nadar”; break;
case 'i' :p=”Steve Jobs”; break;
case 'm' :p=”Bill Gates”; break;
default: =”wrong choice”;}
Ans.
char c;
String p;
if(c=='h') p="Shiv Nadar"; else
if(c=='i') p="Steve Jobs"; else
if(c=='m') p="Bill Gates"; else
p="Wrong Choice";