JAVA QUESTIONS


QUESTION NO : 1
QUESTION STATEMENT :
The ___ method of JFrame is used to attach JMenuBar to it. (write only method name, without braces. e.g. myMethod and note myMethod())


CHOICES :

a) ""


CORRECT ANSWER :
setJMenuBar


EXPLANATION :
The setJMenuBar() method is use to attach JMenuBar to JFrame.


--------------------------------------------------------------------



QUESTION NO : 2
QUESTION STATEMENT : A ___ object can store and retrieve "value" objects indexed by "key" object.

CHOICES :

a) Hashtable
b) HashTable


CORRECT ANSWER : a

EXPLANATION :
A "Hashtable" object can store and retrieve "value" objects indexed by "key" object. A Hashtable can only store one "value" per "key".


--------------------------------------------------------------------



QUESTION NO : 3
QUESTION STATEMENT : Garbage collection is performed by a low priority thread.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
Garbage collection is performed by a low priority thread which runs in the background as daemon.


--------------------------------------------------------------------



QUESTION NO : 4
QUESTION STATEMENT :
___ is the normal priority value of a thread.


CHOICES :

a) ""


CORRECT ANSWER :
5


EXPLANATION :
The normal priority value of a thread is 5 , also given by the constant Thread.NORM_PRIORITY.


--------------------------------------------------------------------



QUESTION NO : 5
QUESTION STATEMENT : A Vector can hold object references or primitive types.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, only object references can be held in a Vector.


--------------------------------------------------------------------



QUESTION NO : 6
QUESTION STATEMENT :
Subclasses of the RuntimeException class are called ___ (checked/unchecked) exceptions.


CHOICES :

a) ""


CORRECT ANSWER :
Unchecked


EXPLANATION :
RuntimeException classes are unchecked exceptions, compiler does not check whether they have been handled or not.


--------------------------------------------------------------------



QUESTION NO : 7
QUESTION STATEMENT : An interface type can be converted to any other interface type.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, for an interface to be converted to another , the new one should be a super interface of the old one.


--------------------------------------------------------------------



QUESTION NO : 8
QUESTION STATEMENT : A Vector maintains object references in the order they were added.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, Vector objects maintained the order in which objects are added.


--------------------------------------------------------------------



QUESTION NO : 9
QUESTION STATEMENT : The String class represents a mutable string.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, the String class in java is immutable; once an instance is created, the string it contains can't be changed.


--------------------------------------------------------------------



QUESTION NO : 10
QUESTION STATEMENT :
A ___ variable is not stored as part of its object's persistent state.


CHOICES :

a) ""


CORRECT ANSWER :
transient


EXPLANATION :
A "transient" variable doesn't serialize.


--------------------------------------------------------------------



QUESTION NO : 11
QUESTION STATEMENT : Reader and Writer are abstract classes.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the Reader and Writer are abstract classes at the top of the character stream class hierarchy.


--------------------------------------------------------------------



QUESTION NO : 12
QUESTION STATEMENT :
A component subclass may handle its own events by calling ___ method.


CHOICES :

a) ""


CORRECT ANSWER :
enableEvents


EXPLANATION :
The enableEvents() method is called by a component subclass to handle its own events.


--------------------------------------------------------------------



QUESTION NO : 13
QUESTION STATEMENT :
byte b=(byte)256;
System.out.println(b);

Value of b printed is ___.


CHOICES :

a) ""


CORRECT ANSWER :
0


EXPLANATION :
Since the integer's value (256) is larger than the byte's range (-128 - +127) , the result is the remainder of the division of the integer value by the byte's range (256).


--------------------------------------------------------------------



QUESTION NO : 14
QUESTION STATEMENT : Hashtable class implements which of the following interfaces?

CHOICES :

a) Map
b) List
c) Hash


CORRECT ANSWER : a

EXPLANATION :
A Hashtable implements Map interface. There is no Hash interface in java.


--------------------------------------------------------------------



QUESTION NO : 15
QUESTION STATEMENT :
___ is the superclass (immediate) of the Frame class.


CHOICES :

a) ""


CORRECT ANSWER :
Window


EXPLANATION :
The "Window" class is the parent of the Frame class.


--------------------------------------------------------------------



QUESTION NO : 16
QUESTION STATEMENT :
___ method waits until the thread on which it is called terminates. (Write only method name, without braces. e.g. myMethod and note myMethod())


CHOICES :

a) ""


CORRECT ANSWER :
join


EXPLANATION :
The join() method waits for the current thread to die.


--------------------------------------------------------------------



QUESTION NO : 17
QUESTION STATEMENT : The '>>>' operator performs a signed right shift.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, the >>> performs an unsigned, or logical, right shift.


--------------------------------------------------------------------



QUESTION NO : 18
QUESTION STATEMENT :
String s1 = new String("MyString");
String s2 = new String("MyString");

s1==s2 will return ___.


CHOICES :

a) ""


CORRECT ANSWER :
false


EXPLANATION :
The equals() method in String class compares the values of two Strings while == compares the memory address of the objects being compared. Thus the result of the above comparison will be false.


--------------------------------------------------------------------



QUESTION NO : 19
QUESTION STATEMENT : Every try block should have a corresponding catch block.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, every try block should have either a corresponding catch block or a finally block.


--------------------------------------------------------------------



QUESTION NO : 20
QUESTION STATEMENT : Garbage collection cannot be forced to happen.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, garbage collection can only be suggested, we cannot force it to happen.


--------------------------------------------------------------------



QUESTION NO : 21
QUESTION STATEMENT :
The ___ variable in java is equivalent of a global variable in C/C++.


CHOICES :

a) ""


CORRECT ANSWER :
static


EXPLANATION :
The global equivalent of C/C++ is "static" in java.


--------------------------------------------------------------------



QUESTION NO : 22
QUESTION STATEMENT : A 'char' type can be assigned to a double variable (without casting).

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
Yes, a 'char' type can be assigned to a double without casting because double is large enough to hold any integral type (char is stored as an integer).


--------------------------------------------------------------------



QUESTION NO : 23
QUESTION STATEMENT : Which method of the File class returns true if the file represented is a directory ?

CHOICES :

a) isDir()
b) isDirectory()


CORRECT ANSWER : a

EXPLANATION :
The isDirectory() method returns true if the file represented is a directory.


--------------------------------------------------------------------



QUESTION NO : 24
QUESTION STATEMENT : Anonymous inner classes can't have an explicit constructor.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, an anonymous inner class (class without a name) can't have any explicit constructor.


--------------------------------------------------------------------



QUESTION NO : 25
QUESTION STATEMENT :
The < , <= , > , >= operators all return a result of ___ type.


CHOICES :

a) ""


CORRECT ANSWER :
boolean


EXPLANATION :
All comparison operators return a boolean result.


--------------------------------------------------------------------



QUESTION NO : 26
QUESTION STATEMENT : A component may have multiple listeners for any event type.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
A component can have multiple listener objects registered for the same event.


--------------------------------------------------------------------



QUESTION NO : 27
QUESTION STATEMENT :
A private method may be overridden by a private, friendly, ___, or public method.


CHOICES :

a) ""


CORRECT ANSWER :
protected


EXPLANATION :
Methods can't be overridden to be more private. Thus a private method may be overridden by a private, friendly, "protected", or public method.


--------------------------------------------------------------------



QUESTION NO : 28
QUESTION STATEMENT :
A ___ class may not be subclassed.


CHOICES :

a) ""


CORRECT ANSWER :
final


EXPLANATION :
A "final" class may not be subclassed.


--------------------------------------------------------------------



QUESTION NO : 29
QUESTION STATEMENT :
The___ operator tests the type of an object at runtime.


CHOICES :

a) ""


CORRECT ANSWER :
instanceof


EXPLANATION :
The 'instanceof' operator tests if an object belongs to a given type.


--------------------------------------------------------------------



QUESTION NO : 30
QUESTION STATEMENT :
The ___ method returns true if the thread upon which it is called is still running.


CHOICES :

a) ""


CORRECT ANSWER :
isAlive


EXPLANATION :
The isAlive() method returns true if a thread on which it is called is running.


--------------------------------------------------------------------



QUESTION NO : 31
QUESTION STATEMENT : The following definition for main method (an entry point of a java application) is valid.

public static void Main(String args[])

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, the above definition is incorrect. Java is case sensitive. Main is a different method from main.


--------------------------------------------------------------------



QUESTION NO : 32
QUESTION STATEMENT :
The___ statement causes the current iteration of the loop to be skipped, the next iteration starts.


CHOICES :

a) ""


CORRECT ANSWER :
continue


EXPLANATION :
The "continue" statement causes the current iteration of the loop to be skipped and the next iteration starts..



--------------------------------------------------------------------



QUESTION NO : 33
QUESTION STATEMENT : A boolean may be converted to integer and vice-versa by casting.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, a boolean cannot be converted to any other type.


--------------------------------------------------------------------



QUESTION NO : 34
QUESTION STATEMENT : The return type of a Constructor in java is "void".

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
The Constructor in java has no return type, not even "void".


--------------------------------------------------------------------



QUESTION NO : 35
QUESTION STATEMENT : The "null" is a reserved java keyword.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, "null" is one of the reserved java keywords.


--------------------------------------------------------------------



QUESTION NO : 36
QUESTION STATEMENT : Constructing an instance of File results in the creation of a file on local file system.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, creating instance of File class doesn't cause creation of a file.


--------------------------------------------------------------------



QUESTION NO : 37
QUESTION STATEMENT : The following variable declaration is valid in java.

byte b = 128;

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, the valid range of byte values is -128 to 127.


--------------------------------------------------------------------



QUESTION NO : 38
QUESTION STATEMENT :
The repaint() method causes the AWT system to execute a call to ____ method.


CHOICES :

a) paint
b) update


CORRECT ANSWER :
B


EXPLANATION :
The repaint() method causes a call to the update() method which in turn calls the paint() method.


--------------------------------------------------------------------



QUESTION NO : 39
QUESTION STATEMENT : Which of the following final values of "a" and "b" are correct on execution of the following loop (both a and b are of int type)?

for(a=1; b=4; a{
}

CHOICES :

a) a=1, b=2
b) a=2, b=3
c) a=3, b=4


CORRECT ANSWER : b

EXPLANATION :
The final value "a" will be 2 and "b" will be 3 (a

--------------------------------------------------------------------



QUESTION NO : 40
QUESTION STATEMENT : The "char" type in java is 16 bit and signed.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, the "char" type is 2 byte (i.e. 16 bit) unsigned.


--------------------------------------------------------------------



QUESTION NO : 41
QUESTION STATEMENT : A thread can attain a lock on an object only if the class of that object implements Runnable.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
For a thread to obtain a lock on an object, the object need not implement any interface.


--------------------------------------------------------------------



QUESTION NO : 42
QUESTION STATEMENT :
Java includes a special reference value called ___, which is used inside any method to refer to the current object.


CHOICES :

a) ""


CORRECT ANSWER :
this


EXPLANATION :
The value "this" refers to the object which the current method has been called on.


--------------------------------------------------------------------



QUESTION NO : 43
QUESTION STATEMENT : The "native" modifier applies only to methods while the "volatile" applies only to variables.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True


--------------------------------------------------------------------



QUESTION NO : 44
QUESTION STATEMENT :
The ___ operator creates a single instance of a named class and returns a reference to the object.


CHOICES :

a) ""


CORRECT ANSWER :
new


EXPLANATION :
The new operator is used to create an instance of a class as shown below:

Point p = new Point();


--------------------------------------------------------------------



QUESTION NO : 45
QUESTION STATEMENT :
In an expression, which has 2 operands, one of which is a long and the other is a float the result will be of ___ type.


CHOICES :

a) ""


CORRECT ANSWER :
float


EXPLANATION :
The result of an expression is promoted to float if one operand is a float and the other is an integral type.


--------------------------------------------------------------------



QUESTION NO : 46
QUESTION STATEMENT : If one operand in an operation is a boolean, the other operand can be of integral type.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
Operands should be of compatible types, boolean type is not compatible with any other type.


--------------------------------------------------------------------



QUESTION NO : 47
QUESTION STATEMENT :
The FileNotFoundException is a subclass of ___


CHOICES :

a) ""


CORRECT ANSWER :
IOException


EXPLANATION :
The FileNotFoundException is a subclass of "IOException".


--------------------------------------------------------------------



QUESTION NO : 48
QUESTION STATEMENT : Which method is not used to request for garbage collection ?

CHOICES :

a) System.gc()
b) System.freegc()


CORRECT ANSWER : b

EXPLANATION :
System.gc() is a method used to request for garbage collection.


--------------------------------------------------------------------



QUESTION NO : 49

QUESTION STATEMENT : Which Layout Manager honors the preferred height and width of components?

CHOICES :

a) BorderLayout
b) FlowLayout


CORRECT ANSWER : b

EXPLANATION :
The FlowLayout manager honors the preferred size of components.


--------------------------------------------------------------------



QUESTION NO : 50
QUESTION STATEMENT :
To call another constructor from a constructor (of the same class), the ___ keyword is used.


CHOICES :

a) ""


CORRECT ANSWER :
this


EXPLANATION :
The "this" keyword is used to call another constructor of the same class from a constructor.

e.g. A(int a){}
A() { this(5); }


--------------------------------------------------------------------



QUESTION NO : 51
QUESTION STATEMENT :
In java it is possible and often desirable to create more than one method with the same name, but different parameter lists. This is called method ___.


CHOICES :

a) ""


CORRECT ANSWER :
overloading


EXPLANATION :
The "method overloading" is the term used to indicate two or methods with same name but different parameter lists.


--------------------------------------------------------------------



QUESTION NO : 52
QUESTION STATEMENT : A static inner class doesn't have any reference to an enclosing instance.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, a static inner class doesn't have a reference to an enclosing instance.


--------------------------------------------------------------------



QUESTION NO : 53
QUESTION STATEMENT :
An ___ class provides a way to defer implementation to subclasses.


CHOICES :

a) ""


CORRECT ANSWER :
abstract


EXPLANATION :
An "abstract" class provides a way to defer implementation to subclass.


--------------------------------------------------------------------



QUESTION NO : 54
QUESTION STATEMENT : The '&&' operator might not always evaluate the right hand operand.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
The '&&' operator will not evaluate the right hand operand if the result of the operation is obtained from the left-hand operand alone.


--------------------------------------------------------------------



QUESTION NO : 55
QUESTION STATEMENT : The wait() method cannot be invoked from synchronized code.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
The wait() method can be called only from synchronized functions/blocks.


--------------------------------------------------------------------



QUESTION NO : 56
QUESTION STATEMENT :
The default value of boolean in java is ___.


CHOICES :

a) ""


CORRECT ANSWER :
false


EXPLANATION :
The default value of boolean type in java is "false".


--------------------------------------------------------------------



QUESTION NO : 57
QUESTION STATEMENT : The arguments to case labels of a switch statement cannot be a variable.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
The arguments to case labels of a switch statement should be evaluated to constant values at compile time itself.


--------------------------------------------------------------------



QUESTION NO : 58
QUESTION STATEMENT :
The << operator introduces___ bits at the least significant bit (LSB) position. (write in digit)


CHOICES :

a) ""


CORRECT ANSWER :
0


EXPLANATION :
The << operator shifts the bits to the left and introduces zero bits in the LSB position.


--------------------------------------------------------------------



QUESTION NO : 59
QUESTION STATEMENT :
A class lock is obtained on synchronizing the___ methods of a class.


CHOICES :

a) ""


CORRECT ANSWER :
static


EXPLANATION :
A thread, which calls a synchronized static method of a class , obtains a lock on the class itself.


--------------------------------------------------------------------



QUESTION NO : 60
QUESTION STATEMENT : The Java.lang.System is a ___ class.

CHOICES :

a) abstract
b) static
c) final


CORRECT ANSWER :

EXPLANATION :
System is a final class; it can't be subclassed.


--------------------------------------------------------------------



QUESTION NO : 61
QUESTION STATEMENT : An interface in java can implement another interface.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
Yes, one interface in java can implement another using "extends" keyword.


--------------------------------------------------------------------



QUESTION NO : 62
QUESTION STATEMENT : Following is the correct declaration of method in Java.

public static abstract void myMethod() {}

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, the above declaration is incorrect. A method in java can't be both "abstract" and "static".


--------------------------------------------------------------------



QUESTION NO : 63
QUESTION STATEMENT : The following lines of code inside a method are valid (i.e. will compile):

final MyCar myCar = new MyCar("BMW");
myCar = new Car("Merc");

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
A final object reference variable can't change. Thus the above lines of code will give compilation error.


--------------------------------------------------------------------



QUESTION NO : 64
QUESTION STATEMENT : Implicitly converting an interface type to a class type is never allowed.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
An interface type can be converted to a class type, only if the class implements the interface.


--------------------------------------------------------------------



QUESTION NO : 65
QUESTION STATEMENT : In java a "protected" variable is more accessible than a default variable (variable with no access modifier).

CHOICES :

a) True
b) False


CORRECT ANSWER :

EXPLANATION :
Following are the access modifiers in the increasing order (the first one is least accessible) of the accessibility of the variables with the access modifier:

private < default (no modifier) < protected < public.


--------------------------------------------------------------------



QUESTION NO : 66
QUESTION STATEMENT : Constructors are inherited into subclass.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
Constructors are not inherited into subclass; you must define each form of constructor that your require.


--------------------------------------------------------------------



QUESTION NO : 67
QUESTION STATEMENT :
The ___ class is a wrapper around int data type in java.


CHOICES :

a) ""


CORRECT ANSWER :
Integer


EXPLANATION :
The "Integer" class is a wrapper around int, short and byte.


--------------------------------------------------------------------



QUESTION NO : 68
QUESTION STATEMENT : An overriding method can be defined in the same class as the method it overrides.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, an overriding method can't be defined in the same class as the method it overrides; rather, it must be defined in a subclass.


--------------------------------------------------------------------



QUESTION NO : 69
QUESTION STATEMENT :
A local variable can be accessed by the methods of an inner class only if it is ___.


CHOICES :

a) ""


CORRECT ANSWER :
final


EXPLANATION :
A local variable or formal parameter can be accessed by the methods of an inner class only if it is declared as final.


--------------------------------------------------------------------



QUESTION NO : 70
QUESTION STATEMENT :
A constant variable in java is marked ___.


CHOICES :

a) ""


CORRECT ANSWER :
final


EXPLANATION :
A constant variable in java is marked "final".


--------------------------------------------------------------------



QUESTION NO : 71
QUESTION STATEMENT :
The garbage collector will usually call an object's ___ method just before the object is garbage collected.


CHOICES :

a) ""


CORRECT ANSWER :
finalize


EXPLANATION :
The garbage collector will usually call an object's "finalize" method just before the object is garbage collected.


--------------------------------------------------------------------



QUESTION NO : 72
QUESTION STATEMENT : The java.lang.Math class has ___ constructor.

CHOICES :

a) public
b) private
c) protected


CORRECT ANSWER : b

EXPLANATION :
The Math class has private constructor; it can't be instantiated.


--------------------------------------------------------------------



QUESTION NO : 73
QUESTION STATEMENT : The following declaration of array type in java is correct.

int number[] = new number[12];

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, the above declaration is incorrect. The correct one will be : int number[] = new int[12];


--------------------------------------------------------------------



QUESTION NO : 74
QUESTION STATEMENT : A dead thread cannot be started again.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, a dead thread cannot be restarted , though the object might still exist in memory.


--------------------------------------------------------------------



QUESTION NO : 75
QUESTION STATEMENT :
If double x = 42.3 then the value of "y % 10" will be ___.


CHOICES :

a) ""


CORRECT ANSWER :
2.3


EXPLANATION :
The result of "42.3 % 10" or "42.3 mod 10" will be "2.3".


--------------------------------------------------------------------



QUESTION NO : 76
QUESTION STATEMENT :
If int a = 32 then the value of "a >> 2 " will be ___


CHOICES :

a) ""


CORRECT ANSWER :
8


EXPLANATION :
The value of 35 (00100011) >> 2 will be 00001000 i.e. 8.


--------------------------------------------------------------------



QUESTION NO : 77
QUESTION STATEMENT : CheckboxGroup class is not a visual component.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the CheckboxGroup class is a non-visible class which organizes checkboxes.



--------------------------------------------------------------------



QUESTION NO : 78
QUESTION STATEMENT : The "!" operator inverts the value of a boolean expression.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the "!" operator inverts the value of any boolean expression.


--------------------------------------------------------------------



QUESTION NO : 79
QUESTION STATEMENT : Threads in Java are platform dependent.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the thread implementation in Java is platform dependent.


--------------------------------------------------------------------



QUESTION NO : 80
QUESTION STATEMENT : The mkdir() method of the File class can be used to create a directory and all the parents of the directory.

CHOICES :

a)
True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the mkdir() method can be used to create a directory and all the parent directories.


--------------------------------------------------------------------



QUESTION NO : 81
QUESTION STATEMENT :
An exception can be explicitly thrown using the___ statement.


CHOICES :

a) ""


CORRECT ANSWER :
throw


EXPLANATION :
To throw an exception explicitly, we use the "throw" statement.


--------------------------------------------------------------------



QUESTION NO : 82
QUESTION STATEMENT :
The read() method of FileInputStream returns ___ value when the end of the file is encountered.


CHOICES :

a) ""


CORRECT ANSWER :
-1


EXPLANATION :
The read() method of FileInputStream returns "-1" on end of file.


--------------------------------------------------------------------



QUESTION NO : 83
QUESTION STATEMENT :
The ___ event is generated by a scrollbar (write the class name).


CHOICES :

a) ""


CORRECT ANSWER :
AdjustmentEvent


EXPLANATION :
The AdjustmentEvent is generated by the Scrollbar.


--------------------------------------------------------------------



QUESTION NO : 84
QUESTION STATEMENT : When we invoke notify(), it is not possible to specify which thread is to be notified.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
We cannot specify the thread to be notified when invoking the notify() function.



--------------------------------------------------------------------



QUESTION NO : 85
QUESTION STATEMENT :
For unary operators, if the operand is a byte, char or a short, it is converted to ___.


CHOICES :

a) ""


CORRECT ANSWER :
int


EXPLANATION :
For unary operators, all integral types except long are converted to int.


--------------------------------------------------------------------



QUESTION NO : 86
QUESTION STATEMENT : RandomAccessFile class supports reading and writing of all primitive types.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the RandomAccessFile supports reading and writing of all primitive datatypes.


--------------------------------------------------------------------



QUESTION NO : 87
QUESTION STATEMENT : The Container class is a subclass of the Component class.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the Container class is a concrete (non-abstract) subclass of the Component class.


--------------------------------------------------------------------



QUESTION NO : 88
QUESTION STATEMENT : An Inner Class can be declared private.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, an Inner Class can have any accessibility including private.


--------------------------------------------------------------------



QUESTION NO : 89
QUESTION STATEMENT : The parent class of both Integer and Character class is Number class.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, Number is the parent class for all wrapper classes (Integer, Short, Byte, Long, Float and Double) except Boolean and Character.



--------------------------------------------------------------------



QUESTION NO : 90
QUESTION STATEMENT : An array can be converted to an object of the class Object without casting.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
All arrays are objects. So they can be assigned to any object of class Object.


--------------------------------------------------------------------



QUESTION NO : 91
QUESTION STATEMENT :
System.out is an object of___ class.


CHOICES :

a) ""


CORRECT ANSWER :
PrintStream


EXPLANATION :
System.out is an object of type PrintStream.


--------------------------------------------------------------------



QUESTION NO : 92
QUESTION STATEMENT :
The if statement takes an argument of___ datatype.


CHOICES :

a) ""


CORRECT ANSWER :
boolean


EXPLANATION :
The 'if' condition takes boolean as an argument.


--------------------------------------------------------------------



QUESTION NO : 93
QUESTION STATEMENT :
The overloaded constructor of the ObjectInputStream class takes ____ as its input argument. (Write the class name)


CHOICES :

a) ""


CORRECT ANSWER :
InputStream


EXPLANATION :
The ObjectInputStream class has following constructors

ObjectInputStream() {}
ObjectInputStream(InputStream in) { }


--------------------------------------------------------------------



QUESTION NO : 94
QUESTION STATEMENT : An array of integers can be converted to an array of bytes by casting.

CHOICES :

a) True
b) False


CORRECT ANSWER : b

EXPLANATION :
False, only an array of object references can be assigned to another array.



--------------------------------------------------------------------



QUESTION NO : 95
QUESTION STATEMENT :
The___ method of the MouseEvent class returns the number of mouse clicks. (write only method name, without braces. e.g. myMethod and note myMethod())


CHOICES :

a) ""


CORRECT ANSWER :
getClickCount


EXPLANATION :
The getClickCount() method returns the number of mouseclicks.


--------------------------------------------------------------------



QUESTION NO : 96
QUESTION STATEMENT :
Sleep() method declares___ in it's throws clause. (write the class name)


CHOICES :

a) ""


CORRECT ANSWER :
InterruptedException


EXPLANATION :
The sleep() method throws InterruptedException


--------------------------------------------------------------------



QUESTION NO : 97
QUESTION STATEMENT : For the XOR operation, a 1 bit results only if exactly one operand bit is 1.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
For the XOR operation, a 1 bit results only one operand bit is 1 and the other is 0. If both the operands are 1 or 0, the result will be 0.


--------------------------------------------------------------------



QUESTION NO : 98
QUESTION STATEMENT : A subclass object can be assigned to a super class type without casting.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
Type, a subclass object can be converted to a superclass type implicitly.


--------------------------------------------------------------------



QUESTION NO : 99
QUESTION STATEMENT : The File class has delete() method which deletes the file/directory.

CHOICES :

a) True
b) False


CORRECT ANSWER : a

EXPLANATION :
True, the File class has delete() method which deletes the file or directory denoted by this abstract pathname. It returns true if and only if the file or directory is successfully deleted; false otherwise


--------------------------------------------------------------------



QUESTION NO : 100
QUESTION STATEMENT :
Inner classes may not declare ___ initializers/members unless they are compile time constants.


CHOICES :

a) ""


CORRECT ANSWER :
static


EXPLANATION :
Inner classes may not declare static initializers or static members unless they are compile time constants i.e. static final var = value;

--------------------------------------------------------------------



1 comment:

Galia Co Hagan said...

Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java EE Training in Chennai. or learn thru Java EE Training in Chennai Students.