Professional Documents
Culture Documents
Question 2 of 47
What will be the output when this program is compiled and run from the command line?
Question 4 of 47
Write the name of the method used to schedule a thread for execution?
(Do not enter any space or brackets.)
Question 6 of 47
The following method will compile and run without any problems.
public void switchTest(byte x)
{
switch(x)
{
case 'b': // 1
default : // 2
case -2: // 3
case 80: // 4
}
}
Question 7 of 47
'3b1' is the hex value for the Greek letter alpha in the Unicode.
Write the Unicode literal which can be used to initialize a char variable to alpha.
(Just write what should replace uuuuuu in the following statement?
char alpha = 'uuuuuu' ; )
Question 8 of 47
What will be the result of compiling and running the following program ?
class NewException extends Exception {}
class AnotherException extends Exception {}
public class ExceptionTest
{
public static void main(String[] args) throws Exception
{
try
{
m2();
}
finally
{
m3();
}
catch (NewException e){}
}
public static void m2() throws NewException { throw new
NewException(); }
public static void m3() throws AnotherException{ throw new
AnotherException(); }
}
Question 11 of 47
Using a continue in a while loop causes the loop to break the current iteration and start
the next iteration of the loop.
Question 12 of 47
Question 13 of 47
What will be the result of trying to compile and execute of the following program?
public class TestClass
{
public static void main(String args[] )
{
int i = 0 ;
int[] iA = {10, 20} ;
iA[i] = i = 30 ;
System.out.println(""+ iA[ 0 ] + " " + iA[ 1 ] + " "+i) ;
}
}
Question 14 of 47
What will be the result of attempting to compile and run the following code?
public class PromotionTest
{
public static void main(String args[])
{
int i = 5;
float f = 5.5f;
double d = 3.8;
char c = 'a';
if (i == f) c++;
if (((int) (f + d)) == ((int) f + (int) d)) c += 2;
System.out.println(c);
}
}
Select 1 correct option.
a The code will fail to compile.
b It will print d.
c It will print c.
d It will print b
e It will print a.
Question 15 of 47
Given the following declaration, select the correct way to get the size of the array,
assuming that the array has been initialized.
int[] intArr;
Question 16 of 47
Question 19 of 47
Question 20 of 47
What will be the output when this program is compiled and run from the command line?
Question 21 of 47
Question 22 of 47
Question 23 of 47
Which variables of the encapsulationg class, can an inner class access if the inner class
is defined in a static method of encapsulating class?
Question 24 of 47
Question 25 of 47
Which of the following command line switches is required for the assert statements to be
executed while running a Java class?
Which of the following exceptions can be declared in the throws clause of a method
overriding the method:
public void perform_work( ) throws IOException {...}
Question 27 of 47
Consider :
class A { public void perform_work(){} }
class B extends A { public void perform_work(){} }
class C extends B { public void perform_work(){} }
How can you let perform_work() method of A to be called from an instance method in
C?
Question 28 of 47
What will be the result of attempting to compile and run the following class?
public class TestClass
{
public static void main(String args[ ] )
{
int i, j, k;
i = j = k = 9;
System.out.println(i);
}
}
Question 29 of 47
Question 30 of 47
Which of the following are also called as "short circuit" logical operators?
Question 32 of 47
Which of the given statements are correct for a method that overrides the following
method:
public void add(int a) {...}
Question 33 of 47
Question 34 of 47
Question 35 of 47
Which of the following switches is/are used for controlling the execution of assertions at
run time?
Which lines of code are valid declarations of a native method when occurring within the
declaration of the following class?
public class TestClass
{
// insert declaration of a native method here
}
Question 37 of 47
What should be passed as a command line parameter while running this program so that
it'll print "Good Choice"?
public class TestClass
{
public static void main(String args[])
{
double d = Double.parseDouble(args[0]);
if( Math.floor(d) == ((int)d))
if( Math.ceil(d) == Math.round(d) )
System.out.println("Good Choice");
}
}
Question 39 of 47
Question 40 of 47
Question 41 of 47
Question 43 of 47
What will be the result of attempting to run the following program?(See Exhibit)
public class StringArrayTest
{
public static void main(String args[])
{
String[][][] arr =
{
{ { "a", "b" , "c"}, { "d", "e", null } },
{ {"x"}, null },
{{"y"}},
{ { "z","p"}, {} }
};
System.out.println(arr[0][1][2]);
}
}
You have just written a Java class named AssertTest.java that uses the assertion facility.
Write down the syntax for compiling this program using Javac.
[Do not write the classpath or any other switches, just use the one/ones that is/are
absolutely needed. Start with: javac ...]
Question 45 of 47
Question 46 of 47
Which of the following statments are correct regarding the equals() method?