Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
Using up to four characters what is the Java representation of the number 23 in hex?
(A) 0x17
(B) 0x18
(C) 0x19
(D) 0x20
Ques 2 :
Assume that the value 3929.92 is of type â??floatâ??. How to assign this value after declaring the variable â??interestâ?? of type float?
(A) interest = 3929.92
(B) interest = (Float)3929.92
(C) interest = 3929.92 (float)
(D) interest = 3929.92f
Ques 3 :
Which of the following is considered as a blue print that defines the variables and methods common to all of its objects of a specific kind?
(A) Object
(B) Class
(C) Method
(D) Real data types
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 :
Select the one correct answer. The number of characters in an object of a class String is given by
(A) The member variable called size
(B) The member variable called length
(C) The method size() returns the number of characters.
(D) The method length() returns the number of characters.
Ques 6 :
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 7 :
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 8 :
What is the minimum value of char type. Select the one correct answer.
(A) 0
(B) -215
(C) -28
(D) -215 - 1
Ques 9 :
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 10 :
What will be the output of the program?
class Exc0 extends Exception { }
class Exc1 extends Exc0 { } /* Line 2 */
public class Test
{
public static void main(String args[])
{
try
{
throw new Exc1(); /* Line 9 */
}
catch (Exc0 e0) /* Line 11 */
{
System.out.println("Ex0 caught");
}
catch (Exception e)
{
System.out.println("exception caught");
}
}
}
(A) Ex0 caught
(B) exception caught
(C) Compilation fails because of an error at line 2.
(D) Compilation fails because of an error at line 9.
Ques 11 :
Which of these statements are legal. Select the three correct answers.
a.
int arr[][] = new int[5][5];
b.
int []arr[] = new int[5][5];
c.
int[][] arr = new int[5][5];
d.
int[] arr = new int[5][];
e.
int[] arr = new int[][5];
(A) a, b
(B) a, b, c
(C) a, b, c, d
(D) a, b, c, d, e
Ques 12 :
Is this True or False. In Java a final class must be sub-classed before it can be used.
(A) True
(B) False
Ques 13 :
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 14 :
A class can have many methods with the same name as long as the number of parameters or type of parameters is different. This OOP concept is known as
(A) Method Invocating
(B) Method Overriding
(C) Method Labeling
(D) Method Overloading
Ques 15 :
Given a one dimensional array arr, what is the correct way of getting the number of elements in arr. Select the one correct answer.
(A) arr.length
(B) arr.length - 1
(C) arr.size
(D) arr.length()
Ques 16 :
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 17 :
Is the following statement true or false. The constructor of a class must not have a return type.
(A) true
(B) false
Ques 18 :
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 19 :
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 20 :
Which of the following are legal Java programs. Select the four correct answers.
a.
// The comments come before the package
package pkg;
import java.awt.*;
class C{}
b.
package pkg;
import java.awt.*;
class C{}
c.
package pkg1;
package pkg2;
import java.awt.*;
class C{}
d.
package pkg;
import java.awt.*;
e.
import java.awt.*;
class C{}
f.
import java.awt.*;
package pkg;
class C {}
(A) a, b, c, d
(B) a, b, d, e
(C) b, c, d, e
(D) c, d, e, f
Submit Answer
Don't Refresh the Page !! ...