Java Mock Test 2

Java Mock Test 2

Java Mock Test 2, 10 QUESTIONS

published on June 26, 200919 responses 1
Java Mock Test 2
Next »
1/10

Which of the following Boolean objects will print "false"
------
Boolean b1 = new Boolean("true");
Boolean b2 = new Boolean("TRUE");
Boolean b3 = new Boolean("0");
Boolean b4 = new Boolean("1");
Boolean b5 = new Boolean("T");
Boolean b6 = new Boolean("F");

System.out.println(b1);
System.out.println(b2);
System.out.println(b3);
System.out.println(b4);
System.out.println(b5);
System.out.println(b6);

Hint: 4 choices
b1
b2
b3
b4
b5
b6
2/10

Which is the minimum value of a byte primitive?

3/10

What will happen if you try to compile and run the following code?
------
boolean b = Boolean.parseBoolean("Java");
System.out.println(b);

true
false
Compilation Error
Throws BooleanFormatException at execution time
Throws NullPointerException at execution time
4/10

Which of the following words are valid Java keywords?

Hint: 5 choices
implement
implements
Class
const
throw
throws
assert
instanceOf
5/10

Which of the following blocks of codes define correctly a class in Java?

import aPackage.AClass;
package myPackage;

class MyClass{
}
package myPackage;
import aPackage.AClass;

class MyClass{
}
import aPackage.AClass;

class myPackage.MyClass{
}
package myPackage;
imports aPackage.AClass;

class MyClass{
}
6/10

Which is the default value for a primitive char?

''
' '
'\u0000'
0
'0'
'A'
7/10

What will happen if you try to compile and run the following code?
------
public void function() {
boolean volatile x;
System.out.println(x);
}

true
false
null
nothing
Compilation error
Runtime Error
8/10

What are the shift operators in java?

Hint: 3 choices
<<
>>
<
>>>
<<<
9/10

What are the value of i after the code is executed?
------
int i = 10;
i = i++%5;

10/10

Which of the following operators is used to check if two primitives are equal?

=
==
<>
!=