400 Mock Questions on OCPJP 6 (formerly known as SCJP 1.6)
JUST Rs.300 or 10 USD Send us mail to sales@javabeat.netmore details
Do you have paypal account? Click Here to pay now and get the questions.
Mock Exam - 4
Q1
Which of the following are the correct form of documentation
comments?
A1
//some text here
A2
/*some text here*/
A3
/**some text here*/
A4
all the above
Q2
State the correct formula for minimum/maximum values for integer
primitives where no_of_bits is the size of the type in bits.
A1
2^(no_of_bits-1) / 2^(no_of_bits-1)+1
A2
2^(no_of_bits+1) / 2^(no_of_bits+1)+1
A3
2^(no_of_bits-1) / 2^(no_of_bits-1)-1
A4
all the above
Q3
Which of the following initializes boolean primitive?
A1
Boolean flag=true;
A2
boolean flag=true;
A3
boolean flag=TRUE;
A4
Boolean flag=TRUE;
Q4
which of the following is the correct way to define a class
that will be in the default package
A1
package default;
import java.util.*;
A2
import java.util.*;
package default;
A3
import java.util.*;
A4
all the above
Q5
Which of the following main method in a java application is
correct?
A1
public static void main(String[] args)
A2
public void main(String args[])
A3
public static void main (string[] args)
A4
final public static void main (String[] args)
A5
static public void main(String x[])
A6
static void main (string[] args)
A7
a and e only.
A8
g and d
Q6
Which of the following is default integer primitive
A1
short
A2
int
A3
byte
A4
char
A5
long
Q7
Which of the following is not a reserved word in java
A1
import
A2
finally
A3
friend
A4
goto
Q8
When writing a utility class, someclass, which extends
mainclass class and will be used by several other classes
in a large project. These other classes will be in
different packages.Pick the correct class declaration
A1
class someclass extends mainclass
A2
protected class someclass extends mainclass
A3
public class someclass extends mainclass
A4
none
Q9
Which of the following variable names are
invalid?
A1
example
A2
2sumup
A3
its4u
A4
$money
Q10
Take a look at the following code:
public
static void main (String[] args){
System.out.println(args[1]);
}
The above is compiled and then executed by the
following command line.
java test one two three four
choose the correct output
A1
one
A2
two
A3
three
A4
four
A5
none.
Answers
1
c
2
c Substitute no_of_bits = ( 8 for byte , 16 for short,
16 for char, 32 for int, 64 for long, 32 for float, 64
for double).We get (2^7) / (2^7) -1 for int and so on
for other types
3
b primitive boolean keyword is 'boolean' and boolean
can be only 'true' or 'false'
4
c. there is nothing like explicit declaration for
default package. The class is added to default package
if there is no package statement.
5
h Valid declaration for the main() method must be
public and static, have void as return type and take a
single array of String objects as arguments. The order
of public and static keywords is irrelevant. Also
declaring the method final does not effect the
method's potential to be used as a main()
method.
6
b
7
c . There are no friend functions as in C++.
8
c
9
b
10
b Array index start from 0. So somearray[0] points to
the first element in the array.
400 Mock Questions on OCPJP 6 (formerly known as SCJP 1.6)
JUST Rs.300 or 10 USD Send us mail to sales@javabeat.netmore details