Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
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
Ques 2 :
The initial value of a local variable of type String that is not explicitly initialized and which is defined in a member function of a class. Select the one correct answer.
(A) NULL
(B) ""
(C) null
(D) The local variable must be explicitly assigned.
Ques 3 :
Which of the following is not a return type?
(A) boolean
(B) void
(C) public
(D) Button
Ques 4 :
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 5 :
By which class we can read object from stream?
(A) Reader
(B) ObjectInputStream
(C) ObjectReader
(D) File
Ques 6 :
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 7 :
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[0]);
}
public static void change_i(int i[])
{
int j[] = {2};
i = j;
}
}
(A) The program prints 0.
(B) The program prints 2.
(C) The program prints 1.
(D) The program prints 4.
Ques 8 :
If a base class has a method defined as
void method() { }
Which of the following are legal prototypes in a derived class of this class. Select the two correct answers.
a.
void method() { }
b.
int method() { return 0;}
c.
void method(int i) { }
d.
private void method() { }
(A) b, c
(B) a, d
(C) a, c
(D) b, d
Ques 9 :
What gets printed when the following program is compiled and run? Select the one correct answer.
class test
{
static boolean check;
public static void main(String args[])
{
int i;
if(check == true)
i=1;
else
i=2;
if(i=2) i=i+2;
else i = i + 4;
System.out.println(i);
}
}
(A) 3
(B) 4
(C) 5
(D) The program does not compile because of the statement if(i=2)
Ques 10 :
Which of the following are valid declarations for the main method. Select the three correct answers.
a.
public static void main(String args[]);
b.
public static void main(String []args);
c.
final static public void main (String args[]);
d.
public static int main(String args[]);
e.
public static abstract void main(String args[]);
(A) a, b, c
(B) b, d, e
(C) a, d, c
(D) a, b, e
Ques 11 :
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 12 :
What is the result of compiling and running the following program. Select one correct answer.
public class test
{
public static void main(String args[])
{
int i = -1;
i = i >> 1;
System.out.println(i);
}
}
(A) 255
(B) 128
(C) -1
(D) 1
Ques 13 :
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 14 :
What all gets printed when the following program is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int i=0, j=2;
do {
i=++i;
j--;
} while(j>0);
System.out.println(i);
}
}
(A) 0
(B) 1
(C) 2
(D) The program does not compile because of statement "i=++i;"
Ques 15 :
nt index = 1;
Boolean [] test = new Boolean[3];
Boolean data = test[index];
What is the result?
(A) data has the value of true
(B) The code will not compile.
(C) data has the value of false
(D) data has the value of null
Ques 16 :
Which of these are not legal identifiers.
(A) 1alpha
(B) xy+abc
(C) both A and B
(D) None of the above
Ques 17 :
Which statement about static inner class is true?
(A) A static inner class does not require an instance of the enclosing class.
(B) A static inner class cannot be a static member of outer class.
(C) It must extend enclosing class.
(D) Itâ??s variables and methods must be static.
Ques 18 :
What is the meaning of the return data type void?
(A) An empty memory space is returned so that the developers can utilize it.
(B) void is not supported in Java
(C) void returns no data type.
(D) null
Ques 19 :
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 20 :
When a thread terminates its processing, into what state that thread enters?
(A) Dead state
(B) Waiting state
(C) Running state
(D) Beginning state
Submit Answer
Don't Refresh the Page !! ...