Complete Study Guide & 250 Practice Questions | Pass the OA
Section 1: Java Fundamentals & Basic Syntax (Questions 1–40)
1. Which component of the Java platform is responsible for executing Java
bytecode?
A) JDK
B) JRE
C) JVM
D) JIT
Answer C: ) JVM
Rationale: The Java Virtual Machine (JVM) executes Java bytecode, providing
platform independence. The JDK includes development tools, and the JRE
includes the JVM.
,2. Which of the following is the correct signature for the main method in
Java?
A) `public void main(String[] args)`
B) `public static void main(String args)`
C) `public static void main(String[] args)`
D) `static public void main(String[] args)`
Answer C: ) `public static void main(String[] args)`
Rationale: The main method must be `public`, `static`, return `void`, and
accept a `String[]` parameter.
3. Java bytecode is:
A) The source code written by the programmer
B) The compiled output that runs on any JVM
C) The machine code for a specific processor
D) The Java documentation
Answer B: ) The compiled output that runs on any JVM
Rationale: Bytecode is platform-independent and runs on any JVM, making
Java "write once, run anywhere."
4. A Java source file must have which file extension?
A) .class
,B) .java
C) .jar
D) .jav
Answer B: ) .java
Rationale: Java source files have the `.java` extension; compiled files have
`.class` extension.
5. Which company originally developed Java?
A) Microsoft
B) Sun Microsystems
C) Oracle
D) IBM
Answer B: ) Sun Microsystems
Rationale: Java was developed by Sun Microsystems, which was later
acquired by Oracle.
6. What is the purpose of the `javac` command?
A) To compile Java source code into bytecode
B) To run Java bytecode
C) To create Java documentation
D) To package Java classes
, Answer A: ) To compile Java source code into bytecode
Rationale: `javac` (Java compiler) compiles `.java` files into `.class` bytecode
files.
7. What is the purpose of the `java` command?
A) To compile Java source code
B) To run Java bytecode
C) To create Java documentation
D) To package Java classes
Answer B: ) To run Java bytecode
Rationale: The `java` command launches the JVM to execute compiled
bytecode.
8. Which of the following is NOT a valid Java identifier?
A) myVariable
B) _myVar
C) 123var
D) $myVar
Answer C: ) 123var
Rationale: Identifiers cannot start with a digit (0-9). They can start with a
letter, underscore (_), or dollar sign ($).