This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Q 1 - What is correct syntax for main method of a java class?
A - public static int main(String[] args)
B - public int main(String[] args)
Correct syntax is public static void main(String[] args).
Boolean is a class and is not a keyword.
Q 3 - What is a class in java?
B - class is a special data type.
A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.
Primitive variables like int, float are stored on Stack.
Objects are allocated memory in heap memory space.
True, Static functions can be accessed via class name or via null reference.
True, Compile time error will occur if an int variable is compared with Boolean variable.
Q 8 - What of the following is the default value of a local variable?
Local variables are not assigned any value by default.
Q 9 - What of the following is the default value of an instance variable?
Instance variables are assigned default values based on their types. For example, int variable is assigned 0 and an object type variable is assigned null as default value.
The byte data type is represented by an 8-bit signed two's complement integer.
Minimum value: -128
Maximum value: 127
The short data type is represented by 16-bit signed two's complement integer.
Minimum value: -32,768
Maximum value: 32,767
The int data type is represented by 32-bit signed two's complement integer,
Minimum value: -231
Maximum value: 231-1
The long data type is represented by 64-bit two's complement integer.
Minimum value: -263
Maximum value: 263-1
The float data type is represented by single-precision 32-bit IEEE 754 floating point.
The double data type is represented by double-precision 64-bit IEEE 754 floating point.
The char data type is represented by single 16-bit Unicode character.
Minimum value: '\u0000' (or 0)
Maximum value: '\uffff' (or 65,535)
Q 17 - What is the size of boolean variable?
The boolean data type can take either true or false, but its "size" isn't precisely defined.
True, an empty .java file is a valid source file.
True, a java file can contain one public class and many other non-public classes.
No, a java file can contain only one public class.
Byte variable has default value of 0 if defined as an instance/static variable.
Short variable has default value of 0 if defined as an instance/static variable.
Byte variable has default value of 0 if defined as an instance/static variable.
short variable has default value of 0 if defined as an instance/static variable.
int variable has default value of 0 if defined as an instance/static variable.
Question Number | Answer Key |
---|---|
1 | C |
2 | B |
3 | A |
4 | A |
5 | B |
6 | B |
7 | B |
8 | D |
9 | C |
10 | A |
11 | B |
12 | C |
13 | D |
14 | C |
15 | D |
16 | B |
17 | B |
18 | A |
19 | A |
20 | B |
21 | A |
22 | A |
23 | A |
24 | B |
25 | A |