Question 2 of 61
Question 4 of 61
Question 5 of 61
Question 6 of 61
Which of these methods from the Collection interface return the value true if the
collection object was actually modified by the call?
Question 7 of 61
Question 9 of 61
Question 10 of 61
What will be the result of attempting to compile and run the following code?
public class InitClass
{
public static void main(String args[ ] )
{
InitClass obj = new InitClass(5);
}
int m;
static int i1 = 5;
static int i2 ;
int j = 100;
int x;
public InitClass(int m)
{
System.out.println(i1 + " " + i2 + " " + x + " " + j + " " +
m);
}
{ j = 30; i2 = 40; } // Instance Initializer
static { i1++; } // Static Initializer
}
Question 11 of 61
What will be the result of attempting to compile and run the following program?
public class TestClass
{
public static void main(String args[ ] )
{
Object a, b, c ;
a = new String("A");
b = new String("B");
c = a;
a = b;
System.out.println(""+c);
}
}
Question 12 of 61
Question 15 of 61
Question 16 of 61
Which of the following code fragments show syntactically correct usage of assertions?
a.)
public void assertTest(Vector v)
{
assert v.size() == 10 : v;
}
b.)
public void assertTest(Vector v)
{
assert v : v.addElement("1234");
}
c.)
public void assertTest(Vector v)
{
assert v != null : v = new Vector();
}
d.)
public void assertTest(Vector v)
{
assert v != null : v == null;
}
e.)
public void assertTest(Vector v)
{
assert v.size() == 10 : v.addElement("hello");
}
Question 18 of 61
What is the correct parameter specification for the standard main method?
Question 20 of 61
Overriding method cannot throw any exceptions that are not thrown by the overridden
method.
Question 21 of 61
Which of these combinations of switch expression types and case label value types are
legal within a switch statement?
Question 22 of 61
Question 24 of 61
Consider:
public class Outer
{
int i = 10;
class Inner
{
public void methodA()
{
//line 1.
}
}
}
Which of the following statements are valid at line 1 (Select the best answer).
Question 26 of 61
Question 27 of 61
Question 29 of 61
Any class may be unloaded when none of it's instances and class objects that represent
this class are reachable.
Given the following class, which of these are valid ways of referring to the class from
outside of the package com.enthu?
package com.enthu;
public class Base
{
// ....
// lot of code...
}
Question 31 of 61
What would be the result of attempting to compile and run the following code?
// Filename: TestClass.java
public class TestClass
{
public static void main(String args[])
{
B c = new C();
System.out.println(c.max(10, 20));
}
}
class A
{
int max(int x, int y) { if (x>y) return x; else return y; }
}
class B extends A
{
int max(int x, int y) { return 2 * super.max(x, y) ; }
}
class C extends B
{
int max(int x, int y) { return super.max( 2*x, 2*y); }
}
Question 32 of 61
Assume that a method named 'method1' contains code which may raise a non-runtime
Exception.
What is the correct way to declare that method so that it indicates that it expects the
caller to handle that exception?
Question 33 of 61
Question 34 of 61
Which of the following methods modify the object on which they are called?
Question 36 of 61
Question 37 of 61
Which interface would you use to represent collection having non-unique objects in
order?
(Do not uses spaces or other special characters)
Question 38 of 61
Question 39 of 61
Question 40 of 61
Question 41 of 61
Question 42 of 61
Question 43 of 61
What will be the result of attempting to compile and run the following code?
class TestClass
{
public static void main(String args[] )
{
String str1 = "str1";
String str2 = "str2";
System.out.println( str1.concat(str2) );
System.out.println(str1);
}
}
class B extends A
{
private int i = 30; //1
public int k = 40;
class C extends B
{
}
Question 46 of 61
Question 47 of 61
Which of these are valid expressions to create a string of value "hello world" ?
Question 48 of 61
Question 49 of 61
Question 51 of 61
Given the following definitions and reference declarations, which of these statements are
legal?
interface I1 { }
interface I2 { }
class C1 implements I1 { }
class C2 implements I2 { }
class C3 extends C1 implements I2 { }
C1 o1;
C2 o2;
C3 o3;
Question 53 of 61
What will be the result of attempting to compile and run the following program?
public class TestClass
{
public static void main(String args[])
{
Exception e = null;
throw e;
}
}
Question 55 of 61
What will be written to the standard output when the following program is run?
public class RoundTest
{
public static void main(String args[])
{
double d = 3.5;
int i = (int) d;
i *= (int) Math.round(d);
i *= (int) Math.round(d-6);
System.out.println(i);
}
}
Question 57 of 61
Which of the following code fragments show syntactically correct usage of assertions?
a.)
public void assertTest()
{
int value;
boolean flag;
...
assert value == 10 : flag;
}
b.)
public void assertTest()
{
int value;
boolean flag;
...
assert flag : value == 10 ;
}
c.)
public void assertTest()
{
int value;
boolean flag;
...
assert value : flag;
}
d.)
public void assertTest()
{
int value;
boolean flag;
...
assert value == 10 : value;
}
e.)
public void assertTest()
{
int value;
boolean flag;
...
assert flag : new Integer(value);
}
Which of these is the correct format to use to create the char literal of value a?
Question 60 of 61
Question 61 of 61