Time remaining
:
:
Test Status
CORETEST10
Ques 1 :
Select the one correct answer. The number of characters in an object of a class String is given by
(A) The member variable called size
(B) The member variable called length
(C) The method size() returns the number of characters.
(D) The method length() returns the number of characters.
Ques 2 :
Which of these are core interfaces in the collection framework. Select the one correct answer.
(A) Tree
(B) Array
(C) LinkedList
(D) Map
Ques 3 :
What will be the output of the program?
public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
(A) Finally
(B) Compilation fails
(C) The code runs with no output.
(D) An exception is thrown at runtime.
Ques 4 :
What would be the result?
class test
{
public static void main(String[] args)
{
Date d = new Date(2011343412345L);
DateFormat df = new DateFormat();
System.out.println(df.format(d));
}
}
(A) An exception is thrown at runtime.
(B) 2011343412345L
(C) 26 Sep, 2033
(D) A compile time error.
Ques 5 :
Which statement is true regarding the creation of default constructor?
(A) The default constructor initializes local variables.
(B) The default constructor invokes the constructor of the superclass.
(C) The default constructor initializes the instance variables declared in the class.
(D) When class has only constructor with parameter, the compiler creates a Default constructor
Ques 6 :
Which statement about static inner class is true?
(A) A static inner class does not require an instance of the enclosing class.
(B) A static inner class cannot be a static member of outer class.
(C) It must extend enclosing class.
(D) Itâ??s variables and methods must be static.
Ques 7 :
Which of the following are correct. Select the one correct answer.
(A) An import statement, if defined, must always be the first non-comment statement of the file.
(B) private members are accessible to all classes in the same package.
(C) An abstract class can be declared as final.
(D) Local variables cannot be declared as static.
Ques 8 :
Which statement is true?
public void test(int x)
{
int odd = 1;
if(odd) /* Line 4 */
{
System.out.println("odd");
}
else
{
System.out.println("even");
}
}
(A) "odd" will always be output.
(B) "even" will always be output.
(C) Compilation fails.
(D) "odd" will be output for odd values of x, and "even" for even values.
Ques 9 :
Select the one correct answer. Which method defined in Integer class can be used to convert an Integer object to primitive int type.
(A) valueOf
(B) intValue
(C) getInt
(D) getInteger
Ques 10 :
Select the one correct answer. The number of characters in an object of a class String is given by
(A) The member variable called size.
(B) The member variable called length
(C) The method size() returns the number of characters.
(D) The method length() returns the number of characters.
Ques 11 :
What would be the output?
class Test
{
public static void main(String [] args) throws Exception
{
Vector data = new Vector();
data.add("apple");
data.add("mango");
data.add("papaya");
data.add("cherry");
data.add("banana");
data.add("apple");
System.out.println(getData(data));
}
public static Vector getData(Vector v)
{
return new Vector(new HashSet(v));
}
}
(A) Compile Error
(B) [banana, cherry, papaya, apple, mango]
(C) [banana, cherry, papaya, apple, mango]
(D) [banana, cherry, papaya, apple, apple, mango]
Ques 12 :
Which code determines the int value data closer to, but not greater than, a double value b?
(A) Int data = (int) Math.floor(b);
(B) Int data = (int) Math.abs(b);
(C) Int data = (int) Math.ceil(b);
(D) Int data = (int) Math.min(b);
Ques 13 :
What is the result?
public Class Test implements Runnable
{
public void run(Thread t)
{
System.out.println("Running...");
}
public static void main(String [] args)
{
new thread(new Test()).start();
}
}
(A) Exception is thrown.
(B) Running... will be printed
(C) Compile error.
(D) Program exists without printing anything.
Ques 14 :
What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (RuntimeException ex) /* Line 10 */
{
System.out.print("B");
}
catch (Exception ex1)
{
System.out.print("C");
}
finally
{
System.out.print("D");
}
System.out.print("E");
}
public static void badMethod()
{
throw new RuntimeException();
}
}
(A) BD
(B) BCD
(C) B
(D) BDE
Ques 15 :
Which cannot directly cause a thread to stop executing?
(A) Calling the notify method on an object.
(B) Calling the start method on another Thread object.
(C) Calling a yield method.
(D) Calling wait method on an object.
Ques 16 :
Which statement is true for the Class java.util.HashSet?
(A) The elements in the collection are unique.
(B) The collection is guaranteed to be immutable
(C) The elements in the collection are ordered.
(D) The elements in the collection are synchronized.
Ques 17 :
What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod()
{
throw new Error(); /* Line 22 */
}
}
(A) BC is printed before exiting with an error
(B) Compilation fails.
(C) ABCD
(D) C is printed before exiting with an error message.
Ques 18 :
What is valid returnType for getData?
public Class returnData
{
<returnType> getData(byte a, double z)
{
Rreturn (short)a/z * 10;
}
}
(A) Short
(B) Byte
(C) Int
(D) Double
Ques 19 :
What is the result?
int index = 1;
Boolean [] test = new Boolean[3];
Boolean data = test[index];
(A) data has the value of true
(B) The code will not compile.
(C) data has the value of false
(D) data has the value of null
Ques 20 :
What will be the output of the program?
class Exc0 extends Exception { }
class Exc1 extends Exc0 { } /* Line 2 */
public class Test
{
public static void main(String args[])
{
try
{
throw new Exc1(); /* Line 9 */
}
catch (Exc0 e0) /* Line 11 */
{
System.out.println("Ex0 caught");
}
catch (Exception e)
{
System.out.println("exception caught");
}
}
}
(A) Ex0 caught
(B) exception caught
(C) Compilation fails because of an error at line 2.
(D) Compilation fails because of an error at line 9.
Submit Answer
Don't Refresh the Page !! ...