AllInfoHub Logo

AllInfoHub – MCQ Practice

Classes and Objects – Multiple Choice Questions (MCQs)

  1. 13. What are instance methods?

    • A. Methods declared with the `static` keyword
    • B. Methods that operate on the class itself
    • C. Methods that operate on a specific object of the class
    • D. Methods that are automatically executed
  2. 14. How do you access an instance variable of an object?

    • A. Using the class name followed by the variable name
    • B. Directly by the variable name
    • C. Using the object name followed by the dot operator and the variable name
    • D. Using a special getter method always
  3. 15. How do you call an instance method of an object?

    • A. Using the class name followed by the method name
    • B. Directly by the method name
    • C. Using the object name followed by the dot operator and the method name
    • D. Using a special invoker method always
  4. 16. What are static variables (or class variables)?

    • A. Variables declared within a method
    • B. Variables declared outside any method but within the class with the `static` keyword
    • C. Variables that are unique to each object
    • D. Variables passed as arguments to a method
  5. 17. What are static methods (or class methods)?

    • A. Methods that operate on a specific object
    • B. Methods that are declared without the `static` keyword
    • C. Methods that belong to the class itself and can be called using the class name
    • D. Methods that can only access instance variables
  6. 18. How do you access a static variable?

    • A. Using the object name followed by the variable name
    • B. Directly by the variable name
    • C. Using the class name followed by the dot operator and the variable name
    • D. It cannot be accessed directly
  7. 19. How do you call a static method?

    • A. Using the object name followed by the method name
    • B. Directly by the method name
    • C. Using the class name followed by the dot operator and the method name
    • D. It cannot be called directly
  8. 20. What is method overloading?

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

    • A. Defining a method in a subclass with the same name and parameter list as a method in its superclass
    • B. Defining multiple methods with the same name
    • C. Calling a method of the superclass
    • D. Defining a static method
  10. 22. What is the purpose of the `final` keyword when applied to a class?

    • A. It prevents the class from being instantiated
    • B. It prevents the class from being subclassed (inherited)
    • C. It makes all methods in the class final
    • D. It makes all variables in the class final
  11. 23. What is the purpose of the `final` keyword when applied to a method?

    • A. It prevents the method from being overridden in a subclass
    • B. It makes the method static
    • C. It prevents the method from being called
    • D. It makes the method abstract
  12. 24. What is the purpose of the `final` keyword when applied to a variable?

    • A. It makes the variable static
    • B. It makes the variable abstract
    • C. It makes the variable a constant (its value cannot be changed after initialization)
    • D. It prevents the variable from being accessed