Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
Which of these are legal array declarations or definitions?
(A) int[] []x[];
(B) int x[5];
(C) int *x;
(D) None of above
Ques 2 :
Given the following code snippet;
int salaries[];
int index = 0;
salaries = new int salaries[4];
while (index < 4)
{
salaries[index] = 10000;
index++;
}
What is the value of salaries [3]?
(A) 40000
(B) 50000
(C) 15000
(D) 10000
Ques 3 :
What are the things we have to follow while creating annotations?
(A) methods must not have any throws clauses
(B) methods must not have any parameters
(C) method should return any one of primitive data types
(D) All the above
Ques 4 :
In which all cases does an exception gets generated. Select the two correct answers.
int i = 0, j = 1;
a.
if((i == 0) || (j/i == 1))
b.
if((i == 0) | (j/i == 1))
c.
if((i != 0) && (j/i == 1))
d.
if((i != 0) & (j/i == 1))
(A) a, c
(B) b, c
(C) b, d
(D) a, d
Ques 5 :
By which class we can read object from stream?
(A) Reader
(B) ObjectInputStream
(C) ObjectReader
(D) File
Ques 6 :
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 = 5 >> 2;
y = x >>> 2;
System.out.println(y);
}
}
(A) 5
(B) 2
(C) 80
(D) 0
Ques 7 :
Which of the following are keywords in Java. Select the two correct answers.
a.
friend
b.
NULL
c.
implement
d.
synchronized
e.
throws
(A) d, e
(B) a, b
(C) a, b, c
(D) all of above
Ques 8 :
What gets printed when the following program is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
byte x = 3;
x = (byte)~x;
System.out.println(x);
}
}
(A) 0
(B) 3
(C) -4
(D) none of these
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 :
What is the legal range of values for a variable declared as a byte. Select the one correct answer.
(A) 0 to 255
(B) 0 to 256
(C) -128 to 127
(D) -127 to 128
Ques 11 :
Which of the assignment are not valid.
(A) short s = 28;
(B) float f = 2.3;
(C) double d = 2.3;
(D) int I = '1';
Ques 12 :
What is the result of compiling and running the following program. Select the one correct answer.
class test {
public static void main(String args[]) {
int i,j=0;
for(i=10;i<0;i--) { j++; }
switch(j) {
case (0) :
j=j+1;
case(1):
j=j+2;
break;
case (2) :
j=j+3;
break;
case (10) :
j=j+10;
break;
default :
break;
}
System.out.println(j);
}
}
(A) 1
(B) 2
(C) 0
(D) 3
Ques 13 :
What is the result of compiling and running the following program.
public class test {
public static void main(String args[]) {
String str1="abc";
String str2="def";
String str3=str1.concat(str2);
str1.concat(str2);
System.out.println(str1);
}
}
(A) def
(B) abc
(C) abcabc
(D) abcdef
Ques 14 :
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 = 1 & 7;
y = 3 ^ 6;
System.out.println(x + " " + y);
}
}
(A) 1 3
(B) 3 5
(C) 5 1
(D) 1 5
Ques 15 :
String s = new String("xyz");
Assuming the above declaration, which of the following statements would compile. Select the one correct answer.
(A) s = 2 * s;
(B) int i = s[0];
(C) s = s + s;
(D) s = s >> 2;
Ques 16 :
Which of these statements are true. Select the two correct answers.
a.
For each try block there must be at least one catch block defined.
b.
A try block may be followed by any number of finally blocks.
c.
A try block must be followed by at least one finally or catch block.
d.
If both catch and finally blocks are defined, catch block must precede the finally block.
(A) a, b
(B) c, d
(C) b, d
(D) a, c
Ques 17 :
Which of these are valid declarations for the main method? Select the one correct answer.
(A) public void main();
(B) public static void main(String args[]);
(C) static public void main(String);
(D) public static int main(String args[]);
Ques 18 :
Select the one most appropriate answer. What is the purpose of method parseInt defined in Integer class.
(A) The method converts an integer to a String.
(B) The method is used to convert String to an integer, assuming that the String represents an integer.
(C) The method is used to convert String to Integer class, assuming that the String represents an integer.
(D) The method converts the Integer object to a String.
Ques 19 :
Which of the following statements are correct. Select the four correct answers.
a.
A Java program must have a package statement.
b.
A package statement if present must be the first statement of the program (barring any comments).
c.
If a Java program defines both a package and import statement, then the import statement must come before the package statement.
d.
An empty file is a valid source file.
e.
A Java file without any class or interface definitions can also be compiled.
f.
If an import statement is present, it must appear before any class or interface definitions.
(A) b, d, e, f
(B) a, b, d, f
(C) d, e, a, c
(D) c, d, b, a
Ques 20 :
If result = 2 + 3 * 5, what is the value and type of â??resultâ?? variable?
(A) 17, byte
(B) 25, byte
(C) 17, int
(D) 25, int
Submit Answer
Don't Refresh the Page !! ...