JavaCore Test 2

The number of characters in an object of a class String is given by

Which of these are core interfaces in the collection framework.

What will be the output of the program?

public class Foo 
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}

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));
}
}

Which statement is true regarding the creation of default constructor?

Which statement about static inner class is true?

Which of the following are correct.

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");
}
}

Which method defined in Integer class can be used to convert an Integer object to primitive int type.

The number of characters in an object of a class String is given by

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));
}
}

Which code determines the int value data closer to, but not greater than, a double value b?

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();
}
}

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();
}
}

Which cannot directly cause a thread to stop executing?

Which statement is true for the Class java.util.HashSet?

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 */
}
}

What is valid returnType for getData?


public Class returnData
{
getData(byte a, double z)
{
Rreturn (short)a/z * 10;
}
}

What is the result?


int index = 1;
Boolean [] test = new Boolean[3];
Boolean data = test[index];

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");
}
}
}

Schreibe einen Kommentar