Java Quiz
Question 11.
public class AQuestion
{
private int i
= giveMeJ();
private int j
= 10;
private int giveMeJ()
{
return j;
}
public static void
main(String args[])
{
System.out.println((new AQuestion()).i);
}
}
Answers
Question 12.
public class AQuestion
{
public static
void main(String args[])
{
System.out.println("Before Try");
try
{
}
catch(Throwable t)
{
System.out.println("Inside Catch");
}
System.out.println("At the End");
}
}
public class AQuestion
{
public static void main(String args[])
{
System.out.println("Before Try");
try
{
}
catch(java.io.IOException t)
{
System.out.println("Inside Catch");
}
System.out.println("At the End");
}
}
The class java.lang.Exception
i.
Is public
ii.
Extends Throwable
iii.
Implements Throwable
iv.
Is serializable
Read this piece of code carefully
if("String".trim() == "String".trim())
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
Read this piece of
code carefully
if( "STRING".toUpperCase() == "STRING")
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
Question 17.
The following lines of code
byte b = 0;
b += 1;
Question 18.
The following express
char
c = -1;
Question 19.
Which of the following statements
are true?
Question 20.
All the wrapper classes
(Integer, Boolean, Float, Short, Long, Double and Character)