☕ Introduction to Java – Practice Test
Multiple Choice
1. Java is a:
A. Hardware device
B. Programming language
C. Database system
D. Operating system
2. Who developed Java?
A. Microsoft
B. Apple
C. Sun Microsystems
D. Google
3. Java is known as a platform-independent language because:
A. It uses C++ syntax
B. It runs only on Windows
C. It uses bytecode executed by the JVM
D. It is open source
4. What does JVM stand for?
A. Java Variable Machine
B. Java Virtual Machine
C. Java Verified Machine
D. Java Visual Machine
5. Which file extension is used for Java source code?
A. .class
B. .exe
C. .java
D. .jar
6. Which file is created after compiling a Java program?
A. .java
B. .class
C. .exe
D. .txt
7. Which command is used to compile a Java program?
A. java
B. compile
C. javac
D. run
8. Which command is used to run a Java program?
A. javac
B. execute
C. java
D. runjava
9. Which method is the entry point of a Java program?
A. start()
B. main()
C. run()
D. init()
10. Correct syntax of the main method is:
A. public static void main(String[] args)
B. static void main()
C. public void main(String args)
D. void main()
11. Which keyword is used to define a class in Java?
A. Class
B. define
C. class
D. new
12. Which keyword is used to create an object?
A. class
B. this
C. object
D. new
13. Which of the following is a valid Java identifier?
A. 2value
B. class
C. total_score
D. float
14. Which data type is used to store whole numbers?
A. double
B. char
C. int
D. boolean
15. Which data type stores true or false values?
A. int
B. boolean
C. char
D. float
16. What is the size of an int in Java?
A. 8 bits
B. 16 bits
C. 32 bits
D. 64 bits
17. Which symbol is used for single-line comments in Java?
A. #
B. /* */
C. //
D. <!-- -->
18. Which operator is used for addition?
A. *
B. +
C. -
D. /
19. Which operator is used to compare two values?
A. =
B. !=
C. +=
D. ++
20. What is the output of: [Link](5 + 3);
A. 53
B. 8
C. 5 + 3
D. Error