- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Mock Test
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.
Java Mock Test I
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)
Answer : C
Explaination
Correct syntax is public static void main(String[] args).
Answer : B
Explaination
Boolean is a class and is not a keyword.
Q 3 - What is a class in java?
B - class is a special data type.
Answer : A
Explaination
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.
Answer : A
Explaination
Primitive variables like int, float are stored on Stack.
Answer : B
Explaination
Objects are allocated memory in heap memory space.
Answer : A
Explaination
True, Static functions can be accessed via class name or via null reference.
Answer : B
Explaination
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?
Answer : D
Explaination
Local variables are not assigned any value by default.
Q 9 - What of the following is the default value of an instance variable?
Answer : C
Explaination
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.
Answer : A
Explaination
The byte data type is represented by an 8-bit signed two's complement integer.
Minimum value: -128
Maximum value: 127
Answer : B
Explaination
The short data type is represented by 16-bit signed two's complement integer.
Minimum value: -32,768
Maximum value: 32,767
Answer : C
Explaination
The int data type is represented by 32-bit signed two's complement integer,
Minimum value: -231
Maximum value: 231-1
Answer : D
Explaination
The long data type is represented by 64-bit two's complement integer.
Minimum value: -263
Maximum value: 263-1
Answer : C
Explaination
The float data type is represented by single-precision 32-bit IEEE 754 floating point.
Answer : D
Explaination
The double data type is represented by double-precision 64-bit IEEE 754 floating point.
Answer : B
Explaination
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?
Answer : B
Explaination
The boolean data type can take either true or false, but its "size" isn't precisely defined.
Answer : A
Explaination
True, an empty .java file is a valid source file.
Answer : A
Explaination
True, a java file can contain one public class and many other non-public classes.
Answer : B
Explaination
No, a java file can contain only one public class.
Answer : A
Explianation
Byte variable has default value of 0 if defined as an instance/static variable.
Answer : B
Explaination
Short variable has default value of 0 if defined as an instance/static variable.
Answer : A
Explaination
Byte variable has default value of 0 if defined as an instance/static variable.
Answer : B
Explaination
short variable has default value of 0 if defined as an instance/static variable.
Answer : A
Explaination
int variable has default value of 0 if defined as an instance/static variable.
Answer Sheet
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 |