1.
Which of the
following is true Statement?
A. A class that is
abstract cannot not be instantiated
B. final variable are
constant variable
C. A static variable
indicates there is only one copy of that variable
D. A method defined as
private indicates that it is accessible to all other classes in the same
package
2. Which is a valid keyword in java?
A. int
B. Boolean
C. Integer
D. Instanceof
3. Given :
public class A{
class B{
}
}
On compiling the code using
javac A.java
What all .class files will be
created?"
A.
A.class
B.
B.class
C.
A.class AND B.class
D.
A.class AND A$B.class
4. Given:
public class TestString1 {
public static void main(String[] args) {
String str = "420";
str += 42;
System.out.print(str);
}
}
What is the output?
A. 42
B. 420
C. 462
D. 42042
5. Identify the correct syntax to create a user
defined exception which handles exception at compile time
A. class MyException
extends Exception {}
B. class MyException
extends RuntimeException {}
C. class MyException
extends Error {}
D. None from the option
6.
Which of the
following command will create a non-executable jar file
A. java -cf jarname.jar
classfiles
B. java jarname.jar classfiles
C. java -cf classfiles
jarname.jar
D. None from the option
7.
Exception given
by compiler at compile time are known as
A. checked exception
B. unchecked exception
C. public exception
D. None from the option
8.
Which of the
following is correct Statement for annotation?
A. annotation is
information for compiler
B. none of the options
C. annotation is use for
compilation
D. annotation is use to handle
exception
9.
Which class in java
which can parse primitive types and strings using regular expressions
A. Scanner
B. Reader
C. InputStream
D. BufferedReader
10.
Which of the
following is part of Character stream?
A. FileInputStream
B. BufferedInputStream
C. FileReader
D. ObjectInputStream
11.
Given:
import java.util.*;
public class Example {
public static void main(String[] args) {
// insert code here
set.add(new Integer(2));
set.add(new Integer(1));
System.out.println(set);
}
}
Which code, inserted at line // insert code here, guarantees that this program
will
output [1, 2]?
A. Set set = new
TreeSet();
B. Set set = new
HashSet();
C. Set set = new
LinkedHashSet();
D. None from the option
12.
Given a class whose
instances, when found in a collection of objects, are sorted by using the
compare() method, which statements are
true?
A. The class implements
java.lang.Comparable.
B. The class implements
java.lang.Comparator
C. The interface used to
implement sorting allows this class to define only one sort
sequence
D. The interface used to
implement sorting allows this class to define many different sort
sequences.
13.
Which interface
provides the capability to store objects using a key-value pair?
A. Java.util.Map
B. Java.util.List
C. Java.util.Set
D. Java.util.Collection
14.
Which type of driver
converts JDBC calls into the network protocol used by the database management system
directly?
A. Type 1 driver
B. Type 2 driver
C. Type 3 driver
D. Type 4 driver
15.
Which of the
following methods are needed for loading a database driver in JDBC?
A. registerDriver()
method
B. Class.forName()
C. getDriver()
D. getConnection()
16.
All the method should
be preceded with the keyword _____________ , If the methods of an object should
only be executed by one thread at a time
A. Asynchronized
B. Serialized
C. Synchronized
D. None from the option
17.
Which of the
following synchronized method or block will compile and run without exception?
A. private synchronized
Object o;
B. public synchronized
void go() { /* code here */ }
C. private
synchronized(this) void go() { /* code here */ }
D. void go() {
synchronized(Object.class) { /* code here */ }
18.
An object that can be
used to get information about the types and properties of the columns in a
ResultSet object is _____________________
A. ResultSetMetaData
B. DatabaseMetaData
C. ColumnMetaDeta
D. None from the option
19. Given:
public class MyThread implements Runnable{
//your code here
}
Which method definition in // your code here completes the class?
A. void run()
B. void start()
C. void execute()
D. void runThread()
20.
A call to this
methods invoked on a thread will wait and not return until either the thread
has completed or it is timed out after the specified time.
A. sleep()
B. yeild()
C. join()
D. run()