Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
Which operator is used to perform bitwise exclusive or.
(A) &
(B) ^
(C) |
(D) !
Ques 2 :
The code snippet
if( "Welcome".trim() == "Welcome".trim() )
System.out.println("Equal");
else
System.out.println("Not Equal");
What will be Answer
(A) compile and display â??Equalâ??
(B) compile and display â??Not Equalâ??
(C) cause a compiler error
(D) compile and display NULL
Ques 3 :
2.
Which of these are not legal identifiers. Select the four correct answers.
a.
1alpha
b.
_abcd
c.
xy+abc
d.
transient
e.
account-num
f.
very_long_name
(A) a, c, e
(B) a, c, d, e
(C) c, d, e, f
(D) all of above
Ques 4 :
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));
}
}
What would be the output?
(A) Compile Error
(B) [banana, cherry, papaya, apple, mango]
(C) [banana, cherry, papaya, apple, mango]
(D) [banana, cherry, papaya, apple, apple, mango]
Ques 5 :
What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int x,y;
x = 3 & 5;
y = 3 | 5;
System.out.println(x + " " + y);
}
}
(A) 7 1
(B) 3 7
(C) 1 7
(D) 1 3
Ques 6 :
What are the two parts of a value of type double?
(A) Length, Denominator
(B) Significant Digits, Exponent
(C) Mode, Numerator
(D) Length, Numerator
Ques 7 :
What is returned when the method substring(2, 4) is invoked on the string "example"? Include the answer in quotes as the result is of type String.
(A) "xa"
(B) "am"
(C) "xm"
(D) "xamp"
Ques 8 :
What is the number displayed when the following program is compiled and run.
class test {
public static void main(String args[]) {
test test1 = new test();
System.out.println(test1.xyz(100));
}
public int xyz(int num) {
if(num == 1) return 1;
else return(xyz(num-1) + num);
}
}
(A) 4040
(B) 5050
(C) 4045
(D) 5055
Ques 9 :
Which of the following statements is preferred to create a string "Welcome to Java Programming"?
(A) String str = â??Welcome to Java Programmingâ??
(B) String str = new String( â??Welcome to Java Programmingâ?? )
(C) String str; str = â??Welcome to Java Programmingâ??
(D) String str; str = new String (â??Welcome to Java Programmingâ?? )
Ques 10 :
Using up to four characters, write the Java representation of integer literal 3 in hexadecimal.
(A) 0x03, 0X03, 0X3
(B) 0x04, 0X04, 0X4
(C) 0x05, 0X05, 0X5
(D) none of these
Ques 11 :
What happens when the following program is compiled and run. Select the one correct answer.
public class example
{
int i = 0;
public static void main(String args[])
{
int i = 1;
change_i(i);
System.out.println(i);
}
public static void change_i(int i)
{
i = 2;
i *= 2;
}
}
(A) The program prints 0.
(B) The program prints 2.
(C) The program prints 1.
(D) The program prints 4.
Ques 12 :
What all gets printed when the following gets compiled and run. Select the two correct answers.
public class test {
public static void main(String args[]) {
int i=1, j=1;
try {
i++;
j--;
if(i == j)
i++;
}
catch(ArithmeticException e) {
System.out.println(0);
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.println(1);
}
catch(Exception e) {
System.out.println(2);
}
finally {
System.out.println(3);
}
System.out.println(4);
}
}
a.
0
b.
1
c.
2
d.
3
e.
4
(A) a, b
(B) b, c
(C) c, d
(D) d, e
Ques 13 :
Write down the modifier of a method that makes the method available to all classes in the same package and to all the subclasses of this class.
(A) public
(B) protected
(C) private
(D) default
Ques 14 :
Which of the following are correct. Select all correct answers.
(A) Java provides two operators to do left shift - << and <<<.
(B) >> is the zero fill right shift operator.
(C) >>> is the signed right shift operator.
(D) For positive numbers, results of operators >> and >>> are same.
Ques 15 :
Why we use @Override annotation?
(A) To check whether the subclass method is overrides from the superclass or not
(B) To say to the compiler not to execute this override method.
(C) To say to compiler that this method is deprecated
(D) None of the above
Ques 16 :
What gets written on the screen when the following program is compiled and run. Select the one right answer.
public class test {
public static void main(String args[]) {
int i;
float f = 2.3f;
double d = 2.7;
i = ((int)Math.ceil(f)) * ((int)Math.round(d));
System.out.println(i);
}
}
(A) 4
(B) 5
(C) 6
(D) 9
Ques 17 :
Which of these are legal array declarations or definitions?
(A) int[] []x[];
(B) int x[5];
(C) int *x;
(D) None of above
Ques 18 :
How many numeric data types are supported in Java?
(A) 8
(B) 4
(C) 6
(D) 2
Ques 19 :
Which of the following statement is true about the assert statement. Select the one correct answer.
(A) If a Java class contains assert statements, then it must be compiled with -1.4 option.
(B) When a program having assertions is run, -assertion option must be specified, otherwise the assertions get ignored.
(C) A possible syntax of assert statement is assert logical_expression If logical_expression evaluates to true, the program generates an AssertionError.
(D) The program terminates on its first AssertionError.
Ques 20 :
Which of these are Java keywords. Select the five correct answers
a.
TRUE
b.
volatile
c.
transient
d.
native
e.
interface
f.
then
g.
new
(A) b, d, f, g
(B) a, b, d, g
(C) b, c, d, e, g
(D) d, e, f, g
Submit Answer
Don't Refresh the Page !! ...