✅ 50 MCQs with Answers & Explanations
(All answers are included after each question.)
1. Java originated from which initial project name?
A. Red Project
B. Stealth Project
C. Blue Project
D. Silver Project
Answer: B. Stealth Project
Explanation: Java began as the Stealth Project before being renamed to Green Project.
Chapter 1 Introduction to java
2. Which company initiated the development of Java?
A. Microsoft
B. IBM
C. Sun Microsystems
D. Oracle
Answer: C. Sun Microsystems
Explanation: Java was developed by Sun Microsystems starting from 1990.
Chapter 1 Introduction to java
3. Who led the team that created Java?
A. Ed Frank
B. Patrick Naughton
C. James Gosling
D. Mike Sheridan
Answer: C. James Gosling
Explanation: Gosling is known as the father of Java.
Chapter 1 Introduction to java
4. Java was initially named:
A. Coffee
B. Oak
C. Maple
D. Pine
Answer: B. Oak
Explanation: The language was first called Oak but later renamed Java.
Chapter 1 Introduction to java
5. Why was the name “Oak” changed?
A. It sounded outdated
B. Already registered by another company
C. Too short
D. Conflict with a keyword
Answer: B. Already registered by another company
Explanation: Oak was already trademarked.
Chapter 1 Introduction to java
6. Why was the name “Java” chosen?
A. Named after Java Island coffee
B. Computer term
C. Shorter to type
D. Random choice
Answer: A. Named after Java Island coffee
Explanation: The team consumed coffee from Java Island.
Chapter 1 Introduction to java
7. What is Java’s official symbol?
A. Snake
B. Gear
C. Cup and saucer
D. Shield
Answer: C. Cup and saucer
Explanation: Reflects coffee inspiration.
Chapter 1 Introduction to java
8. When was Java officially announced?
A. 1991
B. 1993
C. 1995
D. 1997
Answer: C. 1995
Explanation: Announced at SunWorld 1995.
Chapter 1 Introduction to java
9. The first JDK version was released in:
A. 1994
B. 1995
C. 1996
D. 1997
Answer: C. 1996
Explanation: JDK 1.0 released January 23, 1996.
Chapter 1 Introduction to java
10. Java is a ______ language.
A. Machine-dependent
B. System-dependent
C. Platform-independent
D. Device-specific
Answer: C. Platform-independent
Explanation: Java was designed to be system independent.
Chapter 1 Introduction to java
11. Which feature ensures Java gives the same output on
any machine?
A. Compiler
B. Portability
C. Interpreted nature
D. Exception handling
Answer: B. Portability
Explanation: Java programs behave the same across platforms.
Chapter 1 Introduction to java
12. Java programs compile into:
A. Machine code
B. Source code
C. Bytecode
D. Native code
Answer: C. Bytecode
Explanation: Java compiler produces bytecode in .class files.
Chapter 1 Introduction to java
13. Bytecode is executed by:
A. CPU directly
B. C compiler
C. JVM
D. Operating system
Answer: C. JVM
Explanation: JVM interprets and runs bytecode.
Chapter 1 Introduction to java
14. Which Java feature ensures faster runtime?
A. IDE
B. JIT compiler
C. Comments
D. Garbage collector
Answer: B. JIT compiler
Explanation: JIT increases execution speed.
Chapter 1 Introduction to java
15. Java is considered secure because:
A. It allows pointers
B. It generates machine code
C. It is tamper-free and virus-free
D. It is closed-source
Answer: C. It is tamper-free and virus-free
Explanation: Java works safely on the Internet.
Chapter 1 Introduction to java
16. Which feature supports network programming?
A. Robust
B. Dynamic
C. Distributed
D. Static
Answer: C. Distributed
Explanation: It includes libraries working with TCP/IP.
Chapter 1 Introduction to java
17. Which feature allows multiple parts of a program to
run simultaneously?
A. Multilevel
B. Multi-user
C. Multithreaded
D. Multiplatform
Answer: C. Multithreaded
Explanation: Supports concurrent execution.
Chapter 1 Introduction to java
18. Java is dynamic because:
A. Bytecode is large
B. It supports runtime changes
C. It skips compilation
D. It uses pointers
Answer: B. It supports runtime changes
Explanation: Applets and dynamic linking included.
Chapter 1 Introduction to java
19. JDK stands for:
A. Java Deployment Kit
B. Java Development Kit
C. Java Debug Kit
D. Java Data Kernel
Answer: B. Java Development Kit
Explanation: JDK includes compiler, libraries, and runtime.
Chapter 1 Introduction to java
20. The PATH variable helps the system to:
A. Locate Java executables
B. Increase memory
C. Run programs faster
D. Connect to the Internet
Answer: A. Locate Java executables
Explanation: It allows access to java, javac, etc. from any directory.
Chapter 1 Introduction to java
21. Which comment type is used for documentation?
A. //
B. /* /
C. /* */
D. #
Answer: C. / /*
Explanation: Used to generate API documentation.
Chapter 1 Introduction to java
22. The default imported Java package is:
A. [Link]
B. [Link]
C. [Link]
D. [Link]
Answer: C. [Link]
Explanation: Automatically imported in every program.
Chapter 1 Introduction to java
23. Every Java program must contain at least one:
A. Object
B. Package
C. Class
D. Import statement
Answer: C. Class
Explanation: Java is purely OOP, so class is mandatory.
Chapter 1 Introduction to java
24. Program execution in Java begins from:
A. Class declaration
B. import statement
C. main() method
D. Constructor
Answer: C. main() method
Explanation: Execution always starts from main().
Chapter 1 Introduction to java
25. Why must main() be static?
A. It returns a value
B. JVM calls it without creating an object
C. It uses less memory
D. It must be private
Answer: B. JVM calls it without creating an object
Explanation: Static allows calling without an instance.
Chapter 1 Introduction to java
26. Why must main() be public?
A. Static methods must be public
B. JVM must access it
C. It stores output
D. It loads libraries
Answer: B. JVM must access it
Explanation: If not public, JVM cannot execute it.
Chapter 1 Introduction to java
27. main() has what return type?
A. int
B. String
C. void
D. boolean
Answer: C. void
Explanation: It does not return any value.
Chapter 1 Introduction to java
28. The correct method header for main() is:
A. static public void main()
B. public static void main(String args[])
C. public main()
D. static main()
Answer: B. public static void main(String args[])
Explanation: This form is recognized by JVM.
Chapter 1 Introduction to java
29. A Java program is saved with extension:
A. .class
B. .java
C. .txt
D. .exe
Answer: B. .java
Explanation: Source code files are .java.
Chapter 1 Introduction to java
30. Java bytecode is stored in files with extension:
A. .java
B. .class
C. .obj
D. .bin
Answer: B. .class
Explanation: Compiler generates .class files.
Chapter 1 Introduction to java
31. The command to compile Java code is:
A. java
B. run
C. compile
D. javac
Answer: D. javac
Explanation: javac compiles .java files.
Chapter 1 Introduction to java
32. The command to run a Java program is:
A. javac [Link]
B. java Hello
C. java [Link]
D. run Hello
Answer: B. java Hello
Explanation: Run the class name without extension.
Chapter 1 Introduction to java
33. Package names must be written in:
A. ALL CAPS
B. Capitalized words
C. lowercase letters
D. camelCase
Answer: C. lowercase letters
Explanation: Package naming uses small letters.
Chapter 1 Introduction to java
34. Class names in Java should be written as:
A. all lowercase
B. ALL CAPS
C. PascalCase
D. snake_case
Answer: C. PascalCase
Explanation: Each word begins with a capital letter.
Chapter 1 Introduction to java
35. Method names should begin with:
A. Uppercase letter
B. Lowercase letter
C. Number
D. Symbol
Answer: B. Lowercase letter
Explanation: Methods follow lowerCamelCase.
Chapter 1 Introduction to java
36. Constants in Java should be written in:
A. camelCase
B. lowercase
C. PascalCase
D. ALL CAPS
Answer: D. ALL CAPS
Explanation: Constants are written in uppercase.
Chapter 1 Introduction to java
37. How many primitive data types does Java have?
A. 6
B. 7
C. 8
D. 10
Answer: C. 8
Explanation: byte, short, int, long, float, double, char, boolean.
Chapter 1 Introduction to java
38. Which data type is used for Unicode characters?
A. byte
B. int
C. char
D. string
Answer: C. char
Explanation: char uses 2 bytes and supports Unicode.
Chapter 1 Introduction to java
39. boolean type stores:
A. Characters
B. Decimal numbers
C. true or false
D. Large integers
Answer: C. true or false
Explanation: boolean is for logical values.
Chapter 1 Introduction to java
40. Arithmetic operators include:
A. &&
B. ||
C. *
D. ==
**Answer: C. ***
Explanation: Arithmetic operators are +, –, *, /, %.
Chapter 1 Introduction to java
41. Java documentation comments are used to create:
A. .txt files
B. HTML API documentation
C. bytecode
D. class diagrams
Answer: B. HTML API documentation
Explanation: /** */ generates documentation.
Chapter 1 Introduction to java
42. Which editor was recommended in the chapter for
writing Java code?
A. Visual Studio
B. Notepad
C. Photoshop
D. Excel
Answer: B. Notepad
Explanation: Notepad, WordPad, etc., are suggested.
Chapter 1 Introduction to java
43. Java is robust mainly because of:
A. Pointers
B. Exception handling & memory management
C. No compilation
D. Static typing
Answer: B. Exception handling & memory management
Explanation: This prevents program crashes.
Chapter 1 Introduction to java
44. Java is interpreted because:
A. It has no compiler
B. Bytecode is interpreted by JVM
C. It runs only scripts
D. It uses HTML
Answer: B. Bytecode is interpreted by JVM
Explanation: JVM interprets .class files.
Chapter 1 Introduction to java
45. High performance in Java is achieved using:
A. Documentation
B. Compiler only
C. JIT compiler
D. Packages
Answer: C. JIT compiler
Explanation: Just-In-Time compiler optimizes execution.
Chapter 1 Introduction to java
46. Java supports dynamic behavior such as:
A. Static binding
B. Automatic deletion
C. Changing programs on Internet (applets)
D. Removing classes
Answer: C. Changing programs on Internet (applets)
Explanation: Java supports runtime dynamic changes.
Chapter 1 Introduction to java
47. Which keyword is used to define a class?
A. define
B. struct
C. class
D. object
Answer: C. class
Explanation: class keyword starts a class declaration.
Chapter 1 Introduction to java
48. Java’s standard output is printed using:
A. [Link]
B. [Link]()
C. [Link]()
D. output()
Answer: B. [Link]()
Explanation: Standard output uses print or println.
Chapter 1 Introduction to java
49. In Java, a class body starts and ends with:
A. ( )
B. [ ]
C. { }
D. < >
Answer: C. { }
Explanation: Blocks in Java use curly braces.
Chapter 1 Introduction to java
50. Java arrays passed to main() have type:
A. Array
B. int[]
C. String[]
D. Object
Answer: C. String[]
Explanation: main() uses String array as its parameter