Java Mock Test 2

Java Mock Test 2

Java Mock Test 2, 10 QUESTIONS

published on June 26, 200997 responses 1 5.0★ / 5

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);

Select the four correct answers
b1
b2
b3
b4
b5
b6

Which is the minimum value of a byte primitive?

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

Which of the following words are valid Java keywords?

Select the five correct answers
implement
implements
Class
const
throw
throws
assert
instanceOf

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{
}

Which is the default value for a primitive char?

''
' '
'\u0000'
0
'0'
'A'

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

What are the shift operators in java?

Select the three correct answers
<<
>>
<
>>>
<<<

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

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

=
==
<>
!=