Q1. Concider the following piece of code
public class Test {
public static void main(String[] args) {
StringBuffer sb1 = new StringBuffer("Hello");
StringBuffer sb2 = new StringBuffer("Hello");
StringBuffer sb3 = sb1;
}
}
Which of the following will return true?
A. (sb1 == sb2)
B. (sb1 == sb3)
C. (sb1.equals(sb2))
D. (sb1.equals(sb3))
B. (sb2 == sb3)
Q2. If you want to place a button in a frame such that its height always
remains constant and its width may vary, then how will you add that button?
A. Place button in the North region.
B. Place button in Center.
C. Place button in East region.
D. Simply add that button, without specifying the region.
E. Place button in the South region.
Q3. Concider the following method:
1) public method() throws IOException {
2)
3) if (oneMoreMethod())
{
4)
5) }
6) }
For throwing an IOException if oneMoreMethod() returns true, which
of the following methods are
correct?
A. At line 2 write; IOException e;
B. At line 4 write; throw e;
C. At line 4 write; throw new IOException("This is an Exception");
D. At line 4 write; throw;
E. At line 4 write; throw IOException;
Q4. Concider the following code:
String s = "Hello"
Which of the following methods can not change the string value of the
string object s?
A. s.concat(" Bye");
B. s.substring(1, 3);
C. s.toUpperCase();
D. s.trim();
E. s.equals("HELLO");
Q5. What will be the output of the following code if compiled and executed.
public class Test
{
static Integer i;
public static void main(String[]
args) {
System.out.println(i);
}
}
A. The code will not compile because i is not initialized.
B. The code will not compile because i can not be accessed without
creating an instance of the class Test.
C. The code will compile and will print null as output.
D. The code will compile but noting will be printed.
E. The code will compile and 0 will be printed as output.
Q6. Which of the following are the keywords of JAVA Language?
A. if
B. then
C. this
D. that
E. NULL
Q7. Which of the following are tha valid identifiers in Java?
A. _3_
B. switchthis
C. %John%
D. $myDollar
E. volatile
Q8. Which of the following keyword is used to access the object lock?
A. wait
B. synchronized
C. notify
D. notifyAll
E. yield
Q9. FilterInputStream can take argument in its constructor of the type:
A. InputStream
B. PrintStream
C. OutputStream
D. RandomAccessFile
E. FileWriter
Q10. If protected modifier is used for a method of a certain class C,
then which of the following statements are true:
A. That method can be called from a subclass of class C.
B. That method can be called from any superclass if class C.
C. That method can be called from any class in the same package.
D. That method can be called by any method in the same class.
E. That method can be called by any class be it is from the same package
or not.
Answers:
1. B, D
2. A, E
3. C
4. A, B, C, D, E
5. C
6. A, C
7. A, B, D
8. B
9. A
10. A, C, D