AllInfoHub Logo

AllInfoHub – MCQ Practice

Classes and Objects – Multiple Choice Questions (MCQs)

  1. 1. What is a class in Java?

    • A. An instance of an object
    • B. A blueprint for creating objects
    • C. A function within a module
    • D. A type of variable
  2. 2. What is an object in Java?

    • A. A blueprint for creating classes
    • B. A specific instance of a class
    • C. A module containing functions
    • D. A type of loop
  3. 3. Which keyword is used to define a class in Java?

    • A. class
    • B. object
    • C. def
    • D. type
  4. 4. What is the process of creating an object from a class called?

    • A. Declaration
    • B. Instantiation
    • C. Initialization
    • D. Definition
  5. 5. Which keyword is used to create an object in Java?

    • A. new
    • B. create
    • C. object
    • D. instance
  6. 6. What is a constructor in Java?

    • A. A method with the same name as the class that is used to initialize objects
    • B. A special keyword for creating classes
    • C. A method used to delete objects
    • D. A return type of a method
  7. 7. Can a class have multiple constructors in Java?

    • A. No
    • B. Only one
    • C. Yes
    • D. but they must have the same parameters
  8. 8. What is constructor overloading in Java?

    • A. Defining multiple constructors in a class with the same name but different parameter lists
    • B. Defining a constructor in a subclass
    • C. Calling a constructor from another class
    • D. Defining a constructor with default parameters
  9. 9. What is the default constructor in Java?

    • A. A constructor with no arguments that is automatically provided if no other constructor is defined
    • B. A constructor with default values for all parameters
    • C. The first constructor defined in the class
    • D. A constructor named 'default'
  10. 10. What is the purpose of the `this` keyword in Java?

    • A. To refer to the current class
    • B. To refer to the superclass
    • C. To create a new object
    • D. To access static members
  11. 11. How can `this` be used within a constructor?

    • A. To call another constructor of the same class
    • B. To access instance variables
    • C. To call instance methods
    • D. All of the above
  12. 12. What are instance variables (or fields)?

    • A. Variables declared within a method
    • B. Variables declared outside any method but within the class
    • C. Variables declared with the `static` keyword
    • D. Variables passed as arguments to a method