Professional Documents
Culture Documents
Worksheet Comp 2
Worksheet Comp 2
Q.9.
Which
?
mple
amongst the following:
char
Tck () the only correct data type
(b) Character
(a) Float
Q.1. In Java, a library of classes
is called . () Integer
(b) a package (c) String
(a) a folder
(d) an application Ans. (b) of the follow
c) a directory will be the output
Ans. (b)
Q.10. What ing
program?
Integer is a . . .
Q.2. inner class class Output{
(a) adapter class (6)
public static void
main (String args
(c) not a class )wrapper class
Integer i
= new Integer(150);
Ans. (d) double x = i.doubleValue);
of a class
Which of the following may be part
Q.3. System.out.print(x);
definition?
(b) instance methods
(a) instance variables
(c) constructors (d) All of these
(b) 1
(e) None of these (a) 150
(d) 150.0
Ans. (d) (c)0
instance of a
object is an Ans. (d)
. . . . . . . .
Q.4. An
(b) class the following classes is not included
(a) program Q.11. Which of
(c) method () data injava.lang?
(a) Class b) Integer
Ans. (b)
is required to (c) Byte () Array
Q.5. The keyword ......
char chr =
Character.toLowerCase(ch);
chr; int n =
(int) chr + 20;
System.out.println(chr + "\t" +a); System.out.println((char)n+"It" + chr);
(a) M 77 (b) 77 M
(c) N 76 (a)ua (6) a 20
(d) 76 N c) a + 20 (d) 87
Ans. (a) Ans.
What will be the output of the
(a)
Q.16. following Q.19. What will be the output of the following
programa?
program ?
publicclass Test{ public class Test {
public static void main(String args[ 1) { public static void main(String args[ ]) {
char chr =
'C'; String str = "Best questions";
int i = 4;
System.out.printin(str.replace('s',' )3
System.out.println(chr + i);
System.out.printin(int) chr + i);
(a) Be t que tion (6) Bet question
(c) Bess quession ()Best questions
(a) 70 (b) 71 Ans. (a)
(c) C+ 4 (d 4+ Cc Q.20. What will be the output of the following
Ans. (b) program ?
Q.17. What will be the output of the following public class Test {
program? public static void main(String args[ D)
public class Test { String str = "- Best questions";
System.out.println(strl.concat(str);
char ch = Character.toUpperCase
(char)n);
System.out.println(ch + " My God!");
(a) Best Answers Best questions
(b) - Best Answers-Best questions
(c) - Best Answers Best questions