Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (RuntimeException ex) /* Line 10 */
{
System.out.print("B");
}
catch (Exception ex1)
{
System.out.print("C");
}
finally
{
System.out.print("D");
}
System.out.print("E");
}
public static void badMethod()
{
throw new RuntimeException();
}
}
(A) BD
(B) BCD
(C) B
(D) BDE
Ques 2 :
Which of the following are true. Select the three correct answers.
a.
A static method may be invoked before even a single instance of the class is constructed.
b.
A static method cannot access non-static methods of the class.
c.
Abstract modifier can appear before a class or a method but not before a variable.
d.
final modifier can appear before a class or a variable but not before a method.
E.
Synchronized modifier may appear before a method or a variable but not before a class.
(A) a,b,c
(B) a,b
(C) b,c,d
(D) all of above
Ques 3 :
Which of the following are true about interfaces. Select the two correct answers.
a.
Methods declared in interfaces are implicitly private.
b.
Variables declared in interfaces are implicitly public, static, and final.
c.
An interface can extend any number of interfaces.
d.
The keyword implements indicate that an interface inherits from another.
(A) a, b
(B) c, d
(C) b, d
(D) b, c
Ques 4 :
Which of the following statements are true. Select the one correct answer.
(A) Arrays in Java are essentially objects.
(B) It is not possible to assign one array to another. Individual elements of array can however be assigned
(C) Array elements are indexed from 1 to size of array.
(D) If a method tries to access an array element beyond its range, a compile warning is generated.
Ques 5 :
Is this true or false. Map interface is derived from the Collection interface.
(A) True
(B) False
Ques 6 :
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 7 :
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 8 :
The initial value of an instance variable of type String that is not explicitly initialized in the program is --. Select the one correct answer.
(A) null
(B) ""
(C) NULL
(D) The instance variable must be explicitly assigned.
Ques 9 :
After the following code fragment, what is the value in fname?
String str;
int fname;
str = "Foolish boy.";
fname = str.indexOf("fool");
(A) 0
(B) 2
(C) -1
(D) 4
Ques 10 :
Which of the following statements is false about objects?
(A) An instance of a class is an object
(B) Objects can access both static and instance data
(C) Objects do not permit encapsulation
(D) Object is the super class of all other classes
Ques 11 :
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 12 :
The class java.lang.Exception is ?
(A) protected
(B) implements Throwable
(C) serializable
(D) extends Throwable
Ques 13 :
What is the name of collection interface used to maintain non-unique elements in order.
(A) Set
(B) List
(C) Map
(D) SortedSet
Ques 14 :
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 15 :
Which cannot directly cause a thread to stop executing?
(A) Calling the notify method on an object.
(B) Calling the start method on another Thread object.
(C) Calling a yield method.
(D) Calling wait method on an object.
Ques 16 :
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 17 :
Which of the following is not a return type?
(A) boolean
(B) void
(C) public
(D) Button
Ques 18 :
What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.
public class ShortCkt {
public static void main(String args[]) {
int i = 0;
boolean t = true;
boolean f = false, b;
b = (t || ((i++) == 0));
b = (f || ((i+=2) > 0));
System.out.println(i);
}
}
(A) 0
(B) 1
(C) 2
(D) 3
Ques 19 :
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 20 :
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[]) {
boolean x = true;
int a;
if(x) a = x ? 1: 2;
else a = x ? 3: 4;
System.out.println(a);
}
}
(A) 1
(B) 2
(C) 3
(D) 4
Submit Answer
Don't Refresh the Page !! ...