Time remaining
:
:
Test Status
CORETEST6
Ques 1 :
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,d,c
(B) b,c,a
(C) d,e
(D) a,b
Ques 2 :
Which of the following statements is true?
(A) The default char data type is a space( â?? â?? ) character.
(B) The default integer data type is â??longâ?? and real data type is â??floatâ??
(C) The default integer data type is â??intâ?? and real data type is â??doubleâ??
(D) The default integer data type is â??intâ?? and real data type is â??floatâ??
Ques 3 :
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 4 :
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[] arr = {1,2,3,4};
call_array(arr[0], arr);
System.out.println(arr[0] + "," + arr[1]);
}
static void call_array(int i, int arr[])
{
arr[i] = 6;
i = 5;
}
}
(A) 1,2
(B) 5,2
(C) 1,6
(D) 5,6
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;
x = -3 >> 1;
x = x >>> 2;
x = x << 1;
System.out.println(x);
}
}
(A) 7
(B) 23
(C) 5
(D) 2147483646
Ques 6 :
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[]) {
String s1 = "abc";
String s2 = "abc";
if(s1 == s2)
System.out.println(1);
else
System.out.println(2);
if(s1.equals(s2))
System.out.println(3);
else
System.out.println(4);
}
}
(A) 1 2
(B) 1 3
(C) 1 4
(D) 2 4
Ques 7 :
How many numeric data types are supported in Java?
(A) 8
(B) 4
(C) 6
(D) 2
Ques 8 :
What would be the results of compiling and running the following class. Select the one correct answer.
class test
{
public static void main()
{
System.out.println("test");
}
}
(A) The program compiles and runs but does not generate any output.
(B) The program compiles and runs generating an output of "test"
(C) The program compiles but does not run.
(D) The program does not compile as there is no main method defined
Ques 9 :
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 10 :
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 11 :
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[]) {
String s1 = "abc";
String s2 = new String("abc");
if(s1 == s2)
System.out.println(1);
else
System.out.println(2);
if(s1.equals(s2))
System.out.println(3);
else
System.out.println(4);
}
}
(A) 1 3
(B) 1 4
(C) 2 3
(D) 2 4
Ques 12 :
Which of the following statements declare class Sample to belong to the payroll.admindept package?
(A) package payroll;package admindept;
(B) package payroll.admindept.Sample;
(C) package payroll.admindept;
(D) import payroll.admindept.*
Ques 13 :
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 14 :
Which expression can be used to access the last element of an array. Select the one correct answer.
(A) array[array.length]
(B) array[array.length - 1]
(C) array[array.length() - 1]
(D) array[array.length()]
Ques 15 :
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 16 :
Which of the following are legal array declarations. Select the three correct answers.
a.
int i[5][];
b.
int i[][];
c.
int []i[];
d.
int i[5][5];
e.
int[][] a;
(A) a, d, e
(B) b, c, d
(C) b, c, e
(D) a, c, e
Ques 17 :
The class java.lang.Exception is ?
(A) protected
(B) implements Throwable
(C) serializable
(D) extends Throwable
Ques 18 :
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 19 :
Which of the following statements are correct. Select the one correct answer.
(A) Each Java file must have exactly one package statement to specify where the class is stored.
(B) If a Java file has both import and package statement, the import statement must come before package statement.
(C) A Java file has at least one class defined.
(D) If a Java file has a package statement, it must be the first statement (except comments).
Ques 20 :
What all gets printed when the following gets compiled and run. Select the two correct answers.
public class example {
public static void main(String args[]) {
int x = 0;
if(x > 0) x = 1;
switch(x) {
case 1: System.out.println(1);
case 0: System.out.println(0);
case 2: System.out.println(2);
break;
case 3: System.out.println(3);
default: System.out.println(4);
break;
}
}
}
A.
0
B.
1
C.
2
D.
3
E.
4
(A) 1, 0, 2
(B) 3, 4
(C) 0, 2
(D) 1
Submit Answer
Don't Refresh the Page !! ...