MCQs
Option A is wrong. This simply copies the object reference into the array.
Option B is wrong. The reference o is set to null, but, oa[0] still maintains the reference to
the Float object.
Option C is correct. The thread of execution will then not have access to the object.
obj.entrySet() method is used to obtain a set that contains the entries in the map.
This method provides set view of the invoking map.
Output:
$ javac Maps.java
$ java Maps
[A=1, B=2, C=3]
What is the output of this program?
class box {
int width;
int height;
int length;
int volume;
box() {
width = 5;
height = 5;
length = 6;
}
void volume() {
volume = width*height*length;
}
}
class constructor_output {
public static void main(String args[])
{
box obj = new box();
obj.volume();
System.out.println(obj.volume);
}
}
None.
output:
$ constructor_output.java
$ constructor_output
150
Two variables with the same name can't be created in a class.
output:
$ javac main_class.java
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Duplicate local variable x
None.
An object that maps keys to values. A map cannot contain duplicate keys; each key can
map to at most one value.
Every class does not need to have a main() method, there can be only one main() method
which is made public.
By the time line 8 has run, the only object without a reference is the one generated as a result of line 6. Remember that "Java is pass by value," so the reference variable x is not affected by the m1() method.
Ref: http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html
A collection is a group of objects, it is similar to String Template Library (STL)
of C++ programming language.
None.