Time remaining
:
:
Test Status
CORETEST7
Ques 1 :
What is the range of values that can be specified for an int. Select the one correct answer.
(A) The range of values is compiler dependent.
(B) -231 to 231 - 1
(C) 231-1 to 231
(D) -215 to 215 - 1
Ques 2 :
Which of the following statements is true?
(A) An exception can be thrown by throw keyword explicitly.
(B) An exception can be thrown by throws keyword explicitly.
Ques 3 :
What happens when the following program is compiled and executed with the command - java test. Select the one correct answer.
class test
{
public static void main(String args[])
{
if(args.length > 0)
System.out.println(args.length);
}
}
(A) The program compiles and runs but does not print anything.
(B) The program compiles and runs and prints 0
(C) The program compiles and runs and prints 1
(D) The program compiles and runs and prints 2
Ques 4 :
What happens when the following program is compiled and then the command "java check it out" is executed. Select the one correct answer.
class check
{
public static void main(String args[])
{
System.out.println(args[args.length-2]);
}
}
(A) The program compiles but generates ArrayIndexOutOfBoundsException exception
(B) The program prints java
(C) The program prints check
(D) The program prints it
Ques 5 :
What happens when the following class is compiled and run. Select one correct answer.
public class test
{
public static void main(String args[])
{
int x = 0, y = 1, z;
if(x)
z = 0;
else
z = 1;
if(y)
z = 2;
else
z = 3;
System.out.println(z);
}
}
(A) The program prints 1
(B) The program prints 2
(C) The program prints 3
(D) The program does not compile because of problems in the if statement.
Ques 6 :
How can you ensure that the memory allocated by an object is freed. Select the one correct answer.
(A) By invoking the free method on the object.
(B) By calling system.gc() method.
(C) By setting all references to the object to new values (say null).
(D) Garbage collection cannot be forced. The programmer cannot force the JVM to free the memory used by an object.
Ques 7 :
All the wrapper classes (Integer, Boolean, Float, Short, Long, Double and Character) in java
(A) are final
(B) are private
(C) are serializable
(D) are immutatable
Ques 8 :
What is the result of compiling and running this program? Select the one correct answer.
public class test
{
public static void main(String args[])
{
int i, j;
int k = 0;
j = 2;
k = j = i = 1;
System.out.println(k);
}
}
(A) The program does not compile as k is being read without being initialized.
(B) The program does not compile because of the statement k = j = i = 1;
(C) The program compiles and runs printing 1.
(D) The program compiles and runs printing 2.
Ques 9 :
What all gets printed when the following code is compiled and run. Select the three correct answers.
class test
{
public static void main(String args[])
{
int i[] = {0,1};
try
{
i[2] = i[0] + i[1];
}
catch(ArrayIndexOutOfBoundsException e1)
{
System.out.println("1");
}
catch(Exception e2)
{
System.out.println("2");
}
finally
{
System.out.println(3);
}
System.out.println("4");
}
}
a.
1
b.
2
c.
3
d.
4
(A) 1 2 4
(B) 4
(C) 1 3 4
(D) 1 2 3
Ques 10 :
Which all lines are part of the output when the following code is compiled and run. Select the nine correct answers.
public class test {
public static void main(String args[]) {
for(int i = 0; i < 3; i++) {
for(int j = 3; j >= 0; j--) {
if(i == j) continue;
System.out.println(i + " " + j);
}
}
}
}
a.
0 0
b.
0 1
c.
0 2
d.
0 3
e.
1 0
f.
1 1
g.
1 2
h.
1 3
i.
2 0
j.
2 1
k.
2 2
l.
2 3
(A) a, b, c, d, e, i, j, k, l
(B) b, c, d, e, g, h, i, j, l
(C) b, c, e, j, k, l, f, h, i
(D) c, d, e, f, g, h, i
Ques 11 :
What gets printed when the following code is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int i = 1;
do {
i--;
} while (i > 2);
System.out.println(i);
}
}
(A) 0
(B) 1
(C) 2
(D) -1
Ques 12 :
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 13 :
A program needs to store the name, salary, and age of employees in years. Which of the following data types should be used to create the Employee class. Select the three correct answers.
a.
char
b.
boolean
c.
Boolean
d.
String
e.
int
f.
double
(A) a,d,f
(B) a,e,f
(C) d,e,f
(D) d,a,e
Ques 14 :
Which all lines are part of the output when the following code is compiled and run. Select the one correct answer.
public class test
{
public static void main(String args[])
{
for(int i = 0; i < 3; i++)
{
for(int j = 3; j <= 0; j--)
{
if(i == j) continue;
System.out.println(i + " " + j);
}
}
}
}
(A) 1 2
(B) 1 3
(C) 2 0
(D) The program does not print anything.
Ques 15 :
Which of these is a legal definition of a method named m assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer.
(A) void m() throws IOException{}
(B) void m() throw IOException{}
(C) void m(void) throws IOException{}
(D) void m() {} throws IOException
Ques 16 :
Consider the following code snippet. What will be assigned to the variable fourthChar, if the code is executed?
String str = new String("Java");
char fourthChar = str.charAt(4);
(A) 'a'
(B) 'v'
(C) throws StringIndexOutofBoundsException
(D) null characater
Ques 17 :
To make a variable defined in a class accessible only to methods defined in the classes in same package, which of the following keyword should be used. Select the one correct answer.
(A) By using the keyword public before the variable.
(B) By using the keyword protected before the variable.
(C) By using the keyword private before the variable.
(D) The variable should not be preceded by any of the above mentioned keywords.
Ques 18 :
Which all lines are part of the output when the following code is compiled and run. Select the six correct answers.
public class test
{
public static void main(String args[])
{
for(int i = 0; i < 3; i++)
{
for(int j = 3; j >= 0; j--)
{
if(i == j) break;
System.out.println(i + " " + j);
}
}
}
}
a.
0 0
b.
0 1
c.
0 2
d.
0 3
e.
1 0
f.
1 1
g.
1 2
h.
1 3
i.
2 0
j.
2 1
k.
2 2
l.
2 3
m.
3 0
N.
3 1
O.
3 2
P.
3 3
(A) a, b, c, f, h, i
(B) c, d, g, h, i, k
(C) b, c, d, g, h, l
(D) d, e, f, g, j, k
Ques 19 :
Which of the following are legal identifier names in Java. Select the two correct answers.
a.
%abcd
b.
$abcd
c.
1abcd
d.
package
e.
_a_long_name
(A) a, c
(B) b, d
(C) b, e
(D) a, e
Ques 20 :
What gets printed on the standard output when the class below is compiled and executed by entering "java test lets see what happens". Select the one correct answer.
public class test
{
public static void main(String args[])
{
System.out.println(args[0]+" "+args[args.length-1]);
}
}
(A) The program will print - java what
(B) The program will print - java test
(C) The program will throw an ArrayIndexOutOfBounds exception.
(D) The program will print - lets happens
Submit Answer
Don't Refresh the Page !! ...