1 )public class AQuestion
{
public void method(StringBuffer sb)
{
System.out.println("StringBuffer Verion");
}
public void method(
String s)
{
System.out.println("String Version");
}
public static void main(String args[])
{
AQuestion question = new AQuestion();
question.method(null);
}
}
Answers
The code does not compile.
The code compiles cleanly and shows "StringBuffer Version".
The code compiles cleanly and shows "String Version"
The code throws an Exception at Runtime.
ans 1
2) An Interface can never be private or protected.
Answers
True
False
ans false
3)
public XXXX extends something1, something2
XXX should be an interface,something1 and something2 need not, for the expression to be legal
XXX should be a class, something1 and something2 must be interfaces for the expression to be legal.
XXX, something1 and something2 must be interfaces for the expression to be legal.
The above statement is alway illegal in
Java as multiple inheritance is not supported.
ans 3
4)
Read this piece of code carefully
if("String".replace('T','t') == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
the code will compile an print "Equal".
the code will compile an print "Not Equal".
the code will cause a compiler error
ans 1
5) Read this piece of code carefully
if("String".replace('g','G') == "String".replace('g','G'))
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
the code will compile an print "Equal".
the code will compile an print "Not Equal".
the code will cause a compiler error
ans 2
6) public class ADirtyOne
{
public static void main(String args[])
{
System.out.println(Math.abs(Integer.MIN_VALUE));
}
}
an attempt to compile and run the above class will
Cause a compiler error.
Cause no error and the value printed on the screen is less than zero.
Cause no error and the value printed on the screen is one more than Integer.MAX_VALUE
Will throw a runtime exception due to overflow - Integer.MAX_VALUE is less in magnitue than Integer.MIN_VALUE.
ans 2
7)
what does the following expression return?
(0.0 == -0.0)
true
false
ans 1
8)
What does the following expression print on the screen?
System.out.println(Math.min(Float.NaN, Float.POSITIVE_INFINITY));
NaN
Infinity
The expression throws a runtime exception - NaN is an illegal argument.
ans 1
8 )Assume that th is an instance holding a
thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs.
True
False
ans 2