1.Which of the following methods is not defined in the java.util.Vector class?
Contains()
toString()
isEmpty()
empty()
addElement()
elementAt()
2.Which of the following methods is used while passing or returning a
java object from the native method?
System.loadClass
System.loadNative
System.loadLibrary
System.callNative
3.Which of the following exceptions is not a checked exception?
ClassNotFoundException
CloneNotSupportedExeorion
NoSuchMethodException
NullPointerException
IllegalAccessException
4.Which of the following is a valid constructor for the DataInputStream class?
DataInputStream(FileInputStream fin)
DataInputStream(
String str)
DataInputStream(File file)
DataInputStream(FileInputStream fin, int size)
5.Which of the following methods is available in the StringBuffer class but not in the String class?
Spilt()
reverse()
regionMatches()
offsetByCodePoints()
6.How many methods are defined by the serializable Interface?
One
Three
Four
None
7.____________ is a highly optimized set of instructions designed to be executed by the Java run-time system.
Bytecode
Firewall
Tetra code
8.There are _____ types of Comments in Java.
One
Two
Three
Four
9.Which of the following statements are true about coupling and cohesion? Each correct answer represents a complete solution. Choose all that apply
High cohesion is necessary to create a well-defined application.
Loose coupling is necessary to create a well-defined application.
High coupling is necessary to create a well-designed application.
Low coupling is necessary to create a well-designed application.
10.Sam works as a software developer for Amrtech info. He writes code using assert as an identifier for a class named KeyTest. Which of the following will he use to compile the KeyTest class successfully?
Javac –source 1.4 KeyTest.java
Javac –source 1.5 KeyTest.java
Javac –source 5 KeyTest.java
11.The ability of an object to store data beyond the life time of the object is called __________
Resistance
Persistence
Reliability
Durability
12.Which of the following are the classes from which another class inherits its behavior.
Super class
Sub class
Parent class
Child class
13.Overloaded methods are a form of _____________ time
polymorphism and overridden methods are form of __________- time polymorphism.
compile, run
run, Compile
14.The statement that calls the constructor of the superclass should be the last statement in the constructor of a subclass.
True
False
15.The capacity of the string buffer can be changed with the ___________ method provided in the class.
Capacity()
ensureCapacity()
16._______________ modifier reduces the amount of data being serialized and improves performance.
Transient
Volatile
Native
17.An assertion can be placed at any location where control will not be reached.
True
False
18.An assert statement checks a Boolean expression during runtime execution.
True
False
19.Requesting for missing files is a common example of ________________ exception.
Checked
Unchecked
Logical
Default
20.A single method can throw only one exception.
True
False
21.___________________ modifier allows the content of a variable to be synchronized across all running threads and ___________________ modifier can be applied only to methods of a class and indicates that the implementation of the method is outside the class.
Native, Transient
Transient, native
Volatile, Transient
Transient, Volatile
Volatile, Native
22.AssertionError contains a default constructor and _________ single-parameter constructors.
8
7
6
9
23.Which of the following statements are true regarding Assertion?
A. An assertion tells the user of the program that something went wrong.
B. An assertion documents some assumption about the program.
C. When an assertion fails, it points out a bug in the programming logic.
D. Assertions are created to deal with problems that might occur during the course of execution of the program.
E. Assertions are written to state assumptions made by the program.
A, B, E
B, C, E
A, C
C, D, E
A, B, C, D
24.Identify the correct answer.
Statement 1: Class variables are initialized only when the class is instantiated.
Statement 2: Instance variables are assigned a default value even before the class is instantiated.
Statement 1 is True, Statement 2 is False.
Statement 1 is False, Statement 2 is True.
Both the statements are True.
Both the statements are False.
25.Which of the following are not the disadvantages of static methods?
Static method can be invoked by using the class name directly.
Static methods can be used to implement behaviors that are not influenced by the state of any instances.
A static method cannot be overridden, although it can be hidden.
Non-static attributes of the class cannot be accessed from within a static method.
26.Which of the following are the advantages of Instance methods?
Instance methods can be overridden and overloaded.
They can be accessed by using an instance of the class using the dot operator.
Static variables cannot be accessed from the instance methods.
Methods having private access in a class are not inherited.
27.Which of the following statements are not true with respect to the finalize method?
Is used to clean external resources such as files and streams that are open.
Garbage collector need not call the finalize method before it collects an instance of an object.
None of the above statements is applicable.
28.Which of the following statements are true about static method?
Static methods state that the method can be called without an object.
Static methods can use only static data and methods.
Static methods cannot be inherited or overridden.
29.Which of the following statements are not true regarding synchronized method modifier?
It is used with a method while implementing threads.
It permits only one
thread access to a block of code at a time.
It permits only two thread access to a block of code at a time
It permits any number of thread access to a block of code at a time.