AllInfoHub Logo

AllInfoHub – MCQ Practice

Introduction to Java – Multiple Choice Questions (MCQs)

  1. 1. What is the primary goal of Java's design?

    • A. To be platform-specific
    • B. To be fast like C++
    • C. To be platform-independent
    • D. To be primarily for web development
  2. 2. Which of the following is NOT a core principle of Java?

    • A. Simple
    • B. Object-Oriented
    • C. Compiled
    • D. Robust
  3. 3. What is the Java Virtual Machine (JVM)?

    • A. A hardware component
    • B. The Java compiler
    • C. An abstract machine that executes Java bytecode
    • D. A text editor for Java code
  4. 4. What is bytecode in Java?

    • A. Source code compiled into machine code
    • B. An intermediate code that can be executed by the JVM
    • C. Assembly language for Java
    • D. A type of comment in Java
  5. 5. Which tool is used to compile Java source code into bytecode?

    • A. javac
    • B. java
    • C. javadoc
    • D. javap
  6. 6. Which tool is used to run Java bytecode?

    • A. javac
    • B. java
    • C. javadoc
    • D. javap
  7. 7. What is the extension of a Java source code file?

    • A. .java
    • B. .class
    • C. .bytecode
    • D. .exe
  8. 8. What is the extension of a compiled Java bytecode file?

    • A. .java
    • B. .class
    • C. .bytecode
    • D. .exe
  9. 9. Which of the following is a valid entry point for a Java application?

    • A. main()
    • B. Main()
    • C. public static void main(String[] args)
    • D. Public Static Void Main(String args[])
  10. 10. What does the `public` access modifier indicate?

    • A. The member is accessible only within the same class
    • B. The member is accessible within the same class and its subclasses
    • C. The member is accessible within the same package
    • D. The member is accessible from any class
  11. 11. What does the `void` keyword indicate in a method declaration?

    • A. The method returns an integer value
    • B. The method does not return any value
    • C. The method returns a boolean value
    • D. The method returns a string value
  12. 12. What is `String[] args` in the `main` method?

    • A. An array of integers passed as command-line arguments
    • B. A single string passed as a command-line argument
    • C. An array of strings passed as command-line arguments
    • D. A list of available system arguments